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


C# IFileSystem.DeleteFile方法代码示例

本文整理汇总了C#中IFileSystem.DeleteFile方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystem.DeleteFile方法的具体用法?C# IFileSystem.DeleteFile怎么用?C# IFileSystem.DeleteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFileSystem的用法示例。


在下文中一共展示了IFileSystem.DeleteFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configure

        /// <summary>
        /// Configures the specified autorun.
        /// </summary>
        /// <param name="autorun">if set to <c>true</c> [autorun].</param>
        /// <param name="fileSystem">The file system.</param>
        public static void Configure(bool autorun, IFileSystem fileSystem)
        {
            var shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser 3", "Media Browser Server.lnk");

            if (!Directory.Exists(Path.GetDirectoryName(shortcutPath)))
            {
                shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Emby", "Emby Server.lnk");
            }

            var startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);

            // Remove lnk from old name
            try
            {
                fileSystem.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Media Browser Server.lnk"));
            }
            catch
            {
                
            }

            if (autorun)
            {
                //Copy our shortut into the startup folder for this user
                File.Copy(shortcutPath, Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk"), true);
            }
            else
            {
                //Remove our shortcut from the startup folder for this user
                fileSystem.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk"));
            }
        }
开发者ID:jrags56,项目名称:MediaBrowser,代码行数:37,代码来源:Autorun.cs

示例2: DeleteImages

        public static void DeleteImages(GalleryImage image, IFileSystem fileSystem, string virtualRoot)
        {
            string imageVirtualPath = virtualRoot + "FullSizeImages/" + image.ImageFile;

            fileSystem.DeleteFile(imageVirtualPath);

            imageVirtualPath = virtualRoot + "WebImages/" + image.WebImageFile;

            fileSystem.DeleteFile(imageVirtualPath);

            imageVirtualPath = virtualRoot + "Thumbnails/" + image.ThumbnailFile;

            fileSystem.DeleteFile(imageVirtualPath);
        }
开发者ID:joedavis01,项目名称:mojoportal,代码行数:14,代码来源:GalleryHelper.cs

示例3: MongoDbRunner

        /// <summary>
        /// usage: local debugging
        /// </summary>
        private MongoDbRunner(IProcessWatcher processWatcher, IPortWatcher portWatcher, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, IMongoBinaryLocator mongoBin, string dataDirectory)
        {
            _fileSystem = fileSystem;
            _port = MongoDbDefaults.DefaultPort;
            _mongoBin = mongoBin;

            MakeMongoBinarysExecutable();

            ConnectionString = "mongodb://localhost:{0}/".Formatted(_port);

            if (processWatcher.IsProcessRunning(MongoDbDefaults.ProcessName) && !portWatcher.IsPortAvailable(_port))
            {
                State = State.AlreadyRunning;
                return;
            }

            if (!portWatcher.IsPortAvailable(_port))
            {
                throw new MongoDbPortAlreadyTakenException("MongoDB can't be started. The TCP port {0} is already taken.".Formatted(_port));
            }

            _fileSystem.CreateFolder(dataDirectory);
            _fileSystem.DeleteFile(@"{0}{1}{2}".Formatted(dataDirectory, System.IO.Path.DirectorySeparatorChar.ToString(), MongoDbDefaults.Lockfile));
            _mongoDbProcess = processStarter.Start(_mongoBin.Directory, dataDirectory, _port, true);

            State = State.Running;
        }
开发者ID:JohannesHoppe,项目名称:Mongo2Go,代码行数:30,代码来源:MongoDbRunner.cs

示例4: StartUp

 public void StartUp()
 {
     if (FileSystem == null)
     {
         FileSystem = IsolatedStorageFileSystem.GetForApplication();
         if (FileSystem.FileExists(_LOG_FILE_PATH))
             FileSystem.DeleteFile(_LOG_FILE_PATH);
     }
 }
开发者ID:knifhen,项目名称:buttercup-swedish,代码行数:9,代码来源:LoggerTest.cs

示例5: MongoDbRunner

        /// <summary>
        /// usage: integration tests
        /// </summary>
        private MongoDbRunner(IPortPool portPool, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, string dataDirectory)
        {
            _fileSystem = fileSystem;
            _port = portPool.GetNextOpenPort();

            ConnectionString = "mongodb://localhost:{0}/".Formatted(_port);

            _dataDirectoryWithPort = "{0}_{1}".Formatted(dataDirectory, _port);
            _fileSystem.CreateFolder(_dataDirectoryWithPort);
            _fileSystem.DeleteFile(@"{0}\{1}".Formatted(_dataDirectoryWithPort, MongoDbDefaults.Lockfile));
            _mongoDbProcess = processStarter.Start(BinariesDirectory, _dataDirectoryWithPort, _port);

            State = State.Running;
        }
开发者ID:Silv3rcircl3,项目名称:Mongo2Go,代码行数:17,代码来源:MongoDbRunner.cs

示例6: Configure

        /// <summary>
        /// Configures the specified autorun.
        /// </summary>
        /// <param name="autorun">if set to <c>true</c> [autorun].</param>
        /// <param name="fileSystem">The file system.</param>
        public static void Configure(bool autorun, IFileSystem fileSystem)
        {
            var shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Emby", "Emby Server.lnk");

            var startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);

            if (autorun)
            {
                //Copy our shortut into the startup folder for this user
                File.Copy(shortcutPath, Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk"), true);
            }
            else
            {
                //Remove our shortcut from the startup folder for this user
                fileSystem.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk"));
            }
        }
开发者ID:dgz,项目名称:Emby,代码行数:22,代码来源:Autorun.cs

示例7: RemoveMediaPath

        /// <summary>
        /// Deletes a shortcut from within a virtual folder, within either the default view or a user view
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="virtualFolderName">Name of the virtual folder.</param>
        /// <param name="mediaPath">The media path.</param>
        /// <param name="appPaths">The app paths.</param>
        /// <exception cref="System.IO.DirectoryNotFoundException">The media folder does not exist</exception>
        public static void RemoveMediaPath(IFileSystem fileSystem, string virtualFolderName, string mediaPath, IServerApplicationPaths appPaths)
        {
            var rootFolderPath = appPaths.DefaultUserViewsPath;
            var path = Path.Combine(rootFolderPath, virtualFolderName);

            if (!Directory.Exists(path))
            {
                throw new DirectoryNotFoundException(string.Format("The media collection {0} does not exist", virtualFolderName));
            }

            var shortcut = Directory.EnumerateFiles(path, ShortcutFileSearch, SearchOption.AllDirectories).FirstOrDefault(f => fileSystem.ResolveShortcut(f).Equals(mediaPath, StringComparison.OrdinalIgnoreCase));

            if (!string.IsNullOrEmpty(shortcut))
            {
                fileSystem.DeleteFile(shortcut);
            }
        }
开发者ID:jrags56,项目名称:MediaBrowser,代码行数:25,代码来源:LibraryHelpers.cs

示例8: MongoDbRunner

        /// <summary>
        /// usage: local debugging
        /// </summary>
        private MongoDbRunner(IProcessWatcher processWatcher, IPortWatcher portWatcher, IFileSystem fileSystem, IMongoDbProcessStarter processStarter)
        {
            _fileSystem = fileSystem;
            _port = MongoDbDefaults.DefaultPort;

            ConnectionString = "mongodb://localhost:{0}/".Formatted(_port);

            if (processWatcher.IsProcessRunning(MongoDbDefaults.ProcessName) && !portWatcher.IsPortAvailable(_port))
            {
                State = State.AlreadyRunning;
                return;
            }

            if (!portWatcher.IsPortAvailable(_port))
            {
                throw new MongoDbPortAlreadyTakenException("MongoDB can't be started. The TCP port {0} is already taken.".Formatted(_port));
            }

            _fileSystem.CreateFolder(MongoDbDefaults.DataDirectory);
            _fileSystem.DeleteFile(@"{0}\{1}".Formatted(MongoDbDefaults.DataDirectory, MongoDbDefaults.Lockfile));
            _mongoDbProcess = processStarter.Start(BinariesDirectory, MongoDbDefaults.DataDirectory, _port, true);

            State = State.Running;
        }
开发者ID:srasch,项目名称:Mongo2Go,代码行数:27,代码来源:MongoDbRunner.cs

示例9: PerformFileDeletionOperation

        /// <summary>
        /// Performs a file deletion.
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="file">The file to delete.</param>
        /// <param name="execute">if set to true, the operation gets executed.</param>
        private void PerformFileDeletionOperation(IFileSystem fileSystem, IFileInfo file, bool execute)
        {
            var eventArgs = new FileDeletionEventArgs(file.FullName, file.Length);

            this.OnDeletingFile(eventArgs);

            if (execute)
            {
                try
                {
                    fileSystem.DeleteFile(file);

                    this.OnDeletedFile(eventArgs);
                }

                catch (AccessException)
                {
                    this.OnFileDeletionError(new FileDeletionErrorEventArgs(file));
                }
            }
        }
开发者ID:dineshkummarc,项目名称:FlagSync,代码行数:27,代码来源:Job.cs

示例10: DeleteAttachmentFile

        public static void DeleteAttachmentFile(IFileSystem fileSystem, FileAttachment attachment, string basePath)
        {
            if (attachment == null) { return; }
            if (string.IsNullOrEmpty(basePath)) { return; }

            if (fileSystem.FileExists(basePath + attachment.ServerFileName))
            {
                fileSystem.DeleteFile(basePath + attachment.ServerFileName);
            }
        }
开发者ID:joedavis01,项目名称:mojoportal,代码行数:10,代码来源:SiteUtils.cs

示例11: DeleteOldFiles

        /// <summary>
        /// Deletes all but the most recent files.
        /// </summary>
        /// <param name="fileSystem">The abstract file system to search the root directory of.</param>
        /// <param name="maxFileAge">The maximum age of the files to keep, or <c>null</c>.</param>
        /// <param name="maxAppInstanceCount">The maximum number of app instances to keep, or <c>null</c>.</param>
        /// <param name="maxTotalFileSize">The maximum total file size to keep, or <c>null</c>.</param>
        public static void DeleteOldFiles( IFileSystem fileSystem, TimeSpan? maxFileAge, int? maxAppInstanceCount, long? maxTotalFileSize )
        {
            var allFiles = FindAllFiles(fileSystem);
            var filesToKeep = FindLatestFiles(fileSystem, maxFileAge, maxAppInstanceCount, maxTotalFileSize);

            foreach( var file in allFiles )
            {
                bool keepFile = false;
                foreach( var f in filesToKeep )
                {
                    if( DataStore.Comparer.Equals(file.DataStoreName, f.DataStoreName) )
                    {
                        keepFile = true;
                        break;
                    }
                }

                if( keepFile )
                    continue;
                else
                    fileSystem.DeleteFile(file.DataStoreName);
            }
        }
开发者ID:MechanicalMen,项目名称:Mechanical2,代码行数:30,代码来源:ProlificDataFileManager.cs

示例12: DeleteAllFiles

        public static void DeleteAllFiles(SharedFileFolder folder, IFileSystem fileSystem, string fileVirtualBasePath, SharedFilesConfiguration config)
        {
            // method implemented by Jean-Michel 2008-07-31

            // TODO: implement check whether versioning is enabled before calling this method
            // if we are keeping versions we should not delete the files

            if (folder == null) { return; }
            if (fileSystem == null) { return; }
            if (string.IsNullOrEmpty(fileVirtualBasePath)) { return; }
            if (folder.FolderId == -1) { return; }

            ArrayList folders = new ArrayList();
            ArrayList files = new ArrayList();
            using (IDataReader reader = SharedFile.GetSharedFiles(folder.ModuleId, folder.FolderId))
            {
                while (reader.Read())
                {
                    files.Add(Convert.ToInt32(reader["ItemID"]));
                }
            }

            using (IDataReader reader = SharedFileFolder.GetSharedFolders(folder.ModuleId, folder.FolderId))
            {
                while (reader.Read())
                {
                    folders.Add(Convert.ToInt32(reader["FolderID"]));
                }
            }

            foreach (int id in files)
            {
                SharedFile sharedFile = new SharedFile(folder.ModuleId, id);
                sharedFile.Delete();

                if (!config.EnableVersioning)
                {
                    fileSystem.DeleteFile(VirtualPathUtility.Combine(fileVirtualBasePath, sharedFile.ServerFileName));

                }
            }

            foreach (int id in folders)
            {
                SharedFileFolder subFolder = new SharedFileFolder(folder.ModuleId, id);

                DeleteAllFiles(subFolder, fileSystem, fileVirtualBasePath, config);

                SharedFileFolder.DeleteSharedFileFolder(id);
            }
        }
开发者ID:joedavis01,项目名称:mojoportal,代码行数:51,代码来源:SharedFilesHelper.cs

示例13: RestoreHistoryFile

        public static bool RestoreHistoryFile(
            int historyId, 
            IFileSystem fileSystem,
            string virtualSourcePath, 
            string virtualHistoryPath)
        {
            bool historyRestored = false;

            if (string.IsNullOrEmpty(virtualSourcePath)) { return historyRestored; }
            if (string.IsNullOrEmpty(virtualHistoryPath)) { return historyRestored; }
            if (fileSystem == null) { return historyRestored; }

            int itemId = 0;
            int moduleId = 0;
            string historyFriendlyName = string.Empty;
            string historyOriginalName = string.Empty;
            string historyServerName = string.Empty;
            DateTime historyUploadDate = DateTime.Now;
            int historyUploadUserID = 0;
            int historyFileSize = 0;

            using (IDataReader reader = SharedFile.GetHistoryFileAsIDataReader(historyId))
            {
                if (reader.Read())
                {
                    itemId = Convert.ToInt32(reader["ItemID"]);
                    moduleId = Convert.ToInt32(reader["ModuleID"]);
                    historyFriendlyName = reader["FriendlyName"].ToString();
                    historyOriginalName = reader["OriginalFileName"].ToString();
                    historyServerName = reader["ServerFileName"].ToString();
                    historyFileSize = Convert.ToInt32(reader["SizeInKB"]);
                    historyUploadUserID = Convert.ToInt32(reader["UploadUserID"]);
                    historyUploadDate = DateTime.Parse(reader["UploadDate"].ToString());

                }
            }

            SharedFile sharedFile = new SharedFile(moduleId, itemId);
            CreateHistory(sharedFile, fileSystem, virtualSourcePath, virtualHistoryPath);

            //File.Move(Path.Combine(historyPath, Path.GetFileName(historyServerName)), Path.Combine(sourcePath, Path.GetFileName(historyServerName)));
            fileSystem.MoveFile(
                VirtualPathUtility.Combine(virtualHistoryPath, historyServerName),
                VirtualPathUtility.Combine(virtualSourcePath, historyServerName),
                true);

            sharedFile.ServerFileName = historyServerName;
            sharedFile.OriginalFileName = historyOriginalName;
            sharedFile.FriendlyName = historyFriendlyName;
            sharedFile.SizeInKB = historyFileSize;
            sharedFile.UploadDate = historyUploadDate;
            sharedFile.UploadUserId = historyUploadUserID;
            historyRestored = sharedFile.Save();
            SharedFile.DeleteHistory(historyId);

            fileSystem.DeleteFile(VirtualPathUtility.Combine(virtualHistoryPath, historyServerName));

            return historyRestored;
        }
开发者ID:joedavis01,项目名称:mojoportal,代码行数:59,代码来源:SharedFilesHelper.cs

示例14: DeleteHistoryFile

        public static void DeleteHistoryFile(int id, IFileSystem fileSystem, string virtualHistoryPath)
        {
            string historyServerName = string.Empty;

            using (IDataReader reader = SharedFile.GetHistoryFileAsIDataReader(id))
            {
                if (reader.Read())
                {

                    historyServerName = reader["ServerFileName"].ToString();

                }
            }

            if (historyServerName.Length > 0)
            {
                //File.Delete(Path.Combine(historyPath, Path.GetFileName(historyServerName)));
                string fullPath = VirtualPathUtility.Combine(virtualHistoryPath, historyServerName);
                fileSystem.DeleteFile(fullPath);

            }
        }
开发者ID:joedavis01,项目名称:mojoportal,代码行数:22,代码来源:SharedFilesHelper.cs

示例15: RemoveOldFile

 internal static void RemoveOldFile(IFileSystem fileSystem)
 {
     string oldFile = typeof(Program).Assembly.Location + ".old";
     try
     {
         if (fileSystem.FileExists(oldFile))
         {
             fileSystem.DeleteFile(oldFile);
         }
     }
     catch
     {
         // We don't want to block the exe from usage if anything failed
     }
 }
开发者ID:xero-github,项目名称:Nuget,代码行数:15,代码来源:Program.cs


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