c# - 独立存储不支持给定路径的格式

标签 c# windows-phone-8

我想在上传到服务器之前计算文件大小,在此之前我通过创建文件夹将文件保存在独立存储中。现在我想获取计算文件大小的路径,但它给出错误“不支持给定路径的格式”

我的代码是:

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);

enter image description here

关于c# - 独立存储不支持给定路径的格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26799365/

相关文章:

c# - 正则表达式不在组中

c# - 什么时候单个语句需要花括号?

c# - ASP.NET MVC 中的语法 View 数据

c# - 如何突出显示 LongListSelector 中的选定项

c# - 在 Windows Phone 8 应用程序中显示带有文本框输入的提示

c# - IronPython 编号 == null?

c# - ViewModel 中的 MediaElement.play()

c# - 通过mvvmcross进行非线性导航

c# - 将实时推文流式传输到 my .net 网站

c# - Random.NextDouble 方法可以返回 '1.0' 吗?