我想在上传到服务器之前计算文件大小,在此之前我通过创建文件夹将文件保存在独立存储中。现在我想获取计算文件大小的路径,但它给出错误“不支持给定路径的格式”
我的代码是:
string filePath = Path.Combine(FolderName, FileName);
string fp = @"ms-appdata:///local//" + imageFolder + "//" + fName; // here I tried "/" and try to append "filePath " directly still throwing same error
FileInfo info = new FileInfo(fp); ////Here it is throwing error "The given path's format is not supported"
var fileLength = new System.IO.FileInfo(fp).Length;
int image_file_size = Convert.ToInt32(fileLength);
该路径的正确格式是什么?
最佳答案
认为这种路径是在 XAML 中获取代码时的路径。如果你想用 System.IO 来做
然后你需要像这样构建路径
string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
FileInfo info = new FileInfo(dbPath);
关于c# - 独立存储不支持给定路径的格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26799365/