当前位置: 首页>>代码示例>>C#>>正文


C# Context.DeleteFile方法代码示例

本文整理汇总了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);
                    }
                }
            }
        }
开发者ID:CarolineCao,项目名称:example_timePilot,代码行数:86,代码来源:DropboxHelper.cs

示例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);
         }
     }
 }
开发者ID:CarolineCao,项目名称:example_timePilot,代码行数:17,代码来源:DropboxHelper.cs

示例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);
         }
     }
 }
开发者ID:CarolineCao,项目名称:example_timePilot,代码行数:17,代码来源:DropboxHelper.cs


注:本文中的Android.Content.Context.DeleteFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。