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 = $@"..Datauploads{filename}";using (FileStream fs = System.IO.File.Create(tempFilename)){ file.CopyTo(fs); fs.Flush();} 解决方案 Windows using Backslash. Linux using Slash. Path.Combine set the right symbol :Path.Combine Method - MSDN 这篇关于.NET Core 中的跨平台文件名处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-20 13:35
查看更多