【问题标题】:The given path's format is not supported in Isolated storage隔离存储不支持给定路径的格式
【发布时间】:2014-11-07 10:41:17
【问题描述】:

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

我的代码是:

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

此路径的正确格式是什么?

【问题讨论】:

  • 这对你有用吗:'Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)'
  • 现在我得到这个平台不支持的错误操作:(

标签: c# windows-phone-8


【解决方案1】:

当您在 XAML 中采购代码时,您会想到这种路径。如果你想使用 System.IO

那么你需要像这样构建路径

string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");   
FileInfo info = new FileInfo(dbPath);

【讨论】:

  • 哇它的工作,非常感谢 Chubosaurus Software :) string FilePath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, filePath);文件信息信息 = 新文件信息(文件路径); var fileLength = new System.IO.FileInfo(FilePath).Length;
【解决方案2】:

这段代码运行正常

string filePath = Path.Combine(FolderName, FileName);
string FilePath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, filePath);
FileInfo info = new FileInfo(FilePath);
var fileLength = new System.IO.FileInfo(FilePath).Length;
int image_file_size = Convert.ToInt32(fileLength);

【讨论】:

    猜你喜欢
    • 2011-11-13
    • 2012-04-21
    • 1970-01-01
    • 2017-09-14
    • 2014-12-08
    • 1970-01-01
    • 1970-01-01
    • 2012-05-15
    相关资源
    最近更新 更多