/// <summary>
/// Delete the indicated application file
/// </summary>
/// <param name="strFilePathName">The file path name to delete</param>
/// <returns>True, if successful; else false</returns>
public async static Task<bool> DeleteAppFile(string strFilePathName)
{
try
{
StorageFile fDelete = null;
if (!strFilePathName.Equals(""))
{
fDelete = await ApplicationData.Current.LocalFolder.GetFileAsync(strFilePathName);
if (fDelete != null)
{
try
{
await fDelete.DeleteAsync();
}
catch (Exception ex)
{
AFFECTS.App.ShowMessage(true, "Error", "DeleteAppFile {" + strFilePathName + "}", ex.Message);
return false;
}
return true;
}
}
else
AFFECTS.App.ShowMessage(true, "Error", "DeleteAppFile", "File path name is empty.");
}
catch (Exception ex)
{
AFFECTS.App.ShowMessage(true, "Error", "DeleteAppFile {" + strFilePathName + "}", ex.Message);
}
return false;
}
也许文件被打开了一些地方?如果你可以看到它在一个图片控件或类似的删除无法运行 – 2013-02-20 11:31:54
我会朝着那个方向 – Sw1a 2013-02-20 13:13:35
如果您将照片加载到BitmapDecoder或BitmapImage它将被锁定,只要BitmapDecoder或BitmapImage是如果您未指定BitmapCacheOption.OnLoad,则使用该属性。那么你也会拒绝访问。 – 2013-02-20 15:10:28