Issue
How to handle file name in System.IO
classes in a cross-platform manner to make it work on Windows and Linux?
For example, I write this code that works perfectly on Windows, however it doesn't create a file on Ubuntu Linux:
var tempFilename = $@"..\Data\uploads\{filename}";
using (FileStream fs = System.IO.File.Create(tempFilename))
{
file.CopyTo(fs);
fs.Flush();
}
Solution
Windows using Backslash. Linux using Slash. Path.Combine set the right symbol :
Path.Combine Method - MSDN
Answered By - user6522773 Answer Checked By - Candace Johnson (WPSolving Volunteer)