Firstly I'd like to recommend that you don't use the full file path. This may work in your debug app but it won't work elsewhere. Use a relative path from where your binary is. I'm guessing your project name is Idea Engine
and you have a subfolder called projectDataSource
where the file projekonumveadi.txt
resides.
using (StreamReader sr = new StreamReader(@"projectDataSource\projekonumveadi.txt"))
{
};
You are reading the entire text so I'm making an assumption that this text file just contains a path to another file. A StreamReader
is overkill if you want all the text.
string projectText = File.ReadAllText(@"projectDataSource\projekonumveadi.txt");
At this point you're making the assumption that the only thing in the file is the path to another file. If this is true then you can subsequently read the next file.
string nextProjectText = File.ReadAllText(projectText);
Again, assuming this new file contains only a single filename then you can open it using a stream
using (FileStream fs = File.OpenRead(nextProjectText))
{
savedCanvas = XamlReader.Load(fs) as Canvas;
};
It is here that I'm confused as you're code is saying the original text file contains a single line that is the name of a second file. That second file contains a single line that is the name of a third file. It is the third file that contains your data. This would be a very, very odd design to me. At a minimum either of the earlier files would contain other data as well. Furthermore it wouldn't make sense to have 1 file point to the next just to point to the next. You should verify your file structure is what you expect.
File 1.txt
----------
file 2.txt
File 2.txt
---------
file 3.dat
File 3.dat
----------
canvas data
At this point I believe your actual error is that the second file contains more than just a filename and hence why you are getting an error.