I’m currently making an app that needs to print out to a text file, I’m having trouble making it portable below is what I have so far
FileStream fs = new FileStream((@"|DataDirectory|\print" + fileName + ".txt"), FileMode.Create, FileAccess.Write);
using (StreamWriter writer = new StreamWriter(fs))
{
write.write("HelloWorld"
}
The error comes on the first line saying im using an invalid character, I’m assuming that is because of the |DataDirectory| but other than that I don’t know how I’d be able to use it on a user’s machine?
Edit: I no longer have the project to check but @leppie’s comment sounds like the issue with my code. The marked answer worked as an alternative
If you’re developing a desktop app, try with this: