本文整理汇总了C#中Android.Content.Context.DeleteFile方法的典型用法代码示例。如果您正苦于以下问题:C# Context.DeleteFile方法的具体用法?C# Context.DeleteFile怎么用?C# Context.DeleteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Content.Context
的用法示例。
在下文中一共展示了Context.DeleteFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: syncDropboxCsvFiles
public void syncDropboxCsvFiles(Context ctx, bool IsNeedToDelete)
{
if (!IsConnected())
{
return;
}
Dictionary<string, DateTime> _AndroidlFilesModifiedDate = new Dictionary<string, DateTime>();
Dictionary<string, byte[]> _AndroidlFilesContent = new Dictionary<string, byte[]>();
var _localFiles = ctx.FileList();
foreach (var _item in _localFiles)
{
if (_item.IndexOf(".csv") <= 0 && _item.IndexOf(".CSV") <= 0)
{
continue;
}
var AndroidfilemodifiedDate = System.IO.File.GetLastWriteTimeUtc(_item);
_AndroidlFilesModifiedDate.Add(_item, AndroidfilemodifiedDate);
}
var _list = new List<MetaData>(); //getMetaData("/", false); // Employee
var _DeletedFileslist = new List<MetaData>();
string number = settings.GetString("pref_phoneNumber", string.Empty);
if (!string.IsNullOrEmpty(number))
{
var _subList = getMetaData("/TimePilot_aPhone/aP" + number, false);
if(_subList.ContainsKey(1))
_list.AddRange(_subList[1].ToList());
if(_subList.ContainsKey(0))
_DeletedFileslist.AddRange(_subList[0].ToList());
}
foreach (var item in _list)
{
if (item.Extension==".csv" || item.Extension==".CSV")
{
if (_AndroidlFilesModifiedDate.ContainsKey(item.Name))
{
var AndroidFileDate = _AndroidlFilesModifiedDate[item.Name];
if (AndroidFileDate < item.UTCDateModified)
{
try
{
byte[] dropboxFileContent = _client.GetFile(item.Path);
SaveAsPrivateFile(ctx, dropboxFileContent, item.Name);
}
catch (DropNet.Exceptions.DropboxException ex)
{
//throw new System.Exception(ex.Message);
}
catch (System.Exception ex)
{
//throw new System.Exception(ex.Message);
}
}
}
else {
byte[] dropboxFileContent = _client.GetFile(item.Path);
SaveAsPrivateFile(ctx, dropboxFileContent, item.Name);
}
}
}
foreach (var item in _DeletedFileslist)
{
if (EmployeeManagement.DeletedFilesName == null)
{
EmployeeManagement.DeletedFilesName = new List<string>();
}
EmployeeManagement.DeletedFilesName.Add(item.Name.Substring(0, item.Name.LastIndexOf(".")-1));
}
if (IsNeedToDelete)
{
var _listTransFile = _list.Where(L => L.Name.Contains("Trans"));
foreach (var item in _DeletedFileslist)
{
var _theFile = _listTransFile.Where(L => item.Name.Equals(L.Name)).FirstOrDefault();
if (_theFile == null)
{
ctx.DeleteFile(item.Name);
}
}
}
}
示例2: ClearChecklogOfEmpolyee
public void ClearChecklogOfEmpolyee(Context ctx, Employee employee)
{
var files = ctx.FileList();
ctx.DeleteFile("Trans-aP" + employee.Number + ".csv");
string number = settings.GetString("pref_phoneNumber", string.Empty);
if (!string.IsNullOrEmpty(number))
{
try
{
_client.Delete("/TimePilot_aPhone/aP" + number + "/Trans-aP" + employee.Number + ".csv");
}
catch (DropNet.Exceptions.DropboxException ex)
{
throw new System.Exception(ex.Message);
}
}
}
示例3: DeleteEmployeeFromDropBoxandLocalFile
public void DeleteEmployeeFromDropBoxandLocalFile(Context ctx, Employee employee)
{
var files = ctx.FileList();
ctx.DeleteFile(employee.Number + ".CSV");
string number = settings.GetString("pref_phoneNumber", string.Empty);
if (!string.IsNullOrEmpty(number) && this.IsLogined())
{
try
{
_client.Delete("/TimePilot_aPhone/aP" + number + "/" + employee.Number + ".CSV");
}
catch(DropNet.Exceptions.DropboxException ex)
{
throw new System.Exception(ex.Message);
}
}
}