It just started by writing unit tests, and now I'm blocked by this situation:
I have a method that has a FileStream object, and I'm trying to pass a string to it. So, I would like to convert my string to a FileStream, and I do this:
File.WriteAllText(string.Concat(Environment.ExpandEnvironmentVariables("%temp%"), @"/test.txt"), testFileContent); //writes my string to a temp file! new FileStream(string.Concat(Environment.ExpandEnvironmentVariables("%temp%"), @"/test.txt"), FileMode.Open) //open that temp file and uses it as a fileStream!
close the file!
But, I think there should be some very simple alternative to converting a string to a Stream file.
Suggestions are welcome! [Note that there are other answers to this question in stackoverflow, but none of them are a direct solution to this]
Thanks in advance!
source share