none
如何判断文件是否存在 RRS feed

  • 问题

  • public async static Task<bool> FileExist(StorageFolder floder, string Filename)
            {
                try
                {
                    StorageFile sampleFile = await floder.GetFileAsync(Filename);
                    if (sampleFile != null)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                catch
                {
    
                    //出错就报不存在?
                    //throw new FileNotFoundException();
                    return false;
                }
            }

    我用以上代码来判断,可是常出现异常。Runtime里面有函数可以判断文件是否存在吗?

                    

    让信任简单起来

    2012年9月5日 13:23

答案

全部回复