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


C# IO.FileType类代码示例

本文整理汇总了C#中System.IO.FileType的典型用法代码示例。如果您正苦于以下问题:C# FileType类的具体用法?C# FileType怎么用?C# FileType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: LocalFile

        /// <summary>
        ///  Initializes a file instance by a absolute path, child name and type.
        ///  This can be userful when filtering non existing files.
        /// </summary>
        /// <param name="man">Reference to manager that requested the file.</param>
        /// <param name="absolute_path">Absolute file/directory path.</param>
        /// <param name="child_name">Name of child file for the directory.</param>
        /// <param name="type">Type of file to create.</param>
        public LocalFile(ManagerEngine man, string absolute_path, string child_name, FileType type)
        {
            this.manager = man;

            if (child_name != "")
                this.absPath = PathUtils.ToUnixPath(absolute_path + "/" + child_name);
            else
                this.absPath = PathUtils.ToUnixPath(absolute_path);

            if (type == FileType.Directory)
                this.dirInfo = new DirectoryInfo(PathUtils.ToOSPath(this.absPath));
            else if (type == FileType.File)
                this.fileInfo = new FileInfo(PathUtils.ToOSPath(this.absPath));
            else {
                // Create file info or dir info
                this.fileInfo = new FileInfo(PathUtils.ToOSPath(this.absPath));
                if (!this.fileInfo.Exists) {
                    this.dirInfo = new DirectoryInfo(PathUtils.ToOSPath(this.absPath));
                    this.fileInfo = null;
                }

                if (this.fileInfo != null)
                    this.absPath = PathUtils.ToUnixPath(this.fileInfo.FullName);

                if (this.dirInfo != null)
                    this.absPath = PathUtils.RemoveTrailingSlash(PathUtils.ToUnixPath(this.dirInfo.FullName));
            }

            this.config = this.manager.Config;
            this.configResolved = false;
            this.triggerEvents = true;
        }
开发者ID:nhtera,项目名称:CrowdCMS,代码行数:40,代码来源:LocalFile.cs

示例2: Insert

        public int Insert(string userId, string path, FileType fileType)
        {
            int id = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Files_Insert"
               , inputParamMapper: delegate(SqlParameterCollection paramCollection)
               {
                   paramCollection.AddWithValue("@UserId", userId);
                   paramCollection.AddWithValue("@Path", path);
                   paramCollection.AddWithValue("@FileType", fileType);

                   SqlParameter p = new SqlParameter("@Id", System.Data.SqlDbType.Int);
                   p.Direction = System.Data.ParameterDirection.Output;

                   paramCollection.Add(p);

               }, returnParameters: delegate(SqlParameterCollection param)
               {
                   int.TryParse(param["@Id"].Value.ToString(), out id);
               }

               );

            return id;
        }
开发者ID:thedevhunter,项目名称:MiDinero-MiFuturo,代码行数:25,代码来源:FilesService.cs

示例3: GetFileName

        static string GetFileName(string name, FileType type)
        {
            var sb = new StringBuilder(256);

            if (type == FileType.Package)
                sb.Append("p_");
            if (type == FileType.File)
                sb.Append("f_");
            if (type == FileType.Directory)
                sb.Append("d_");

            sb = sb.Append(name);
            sb = sb.Replace("\\", "-");
            sb = sb.Replace("/", "-");
            sb = sb.Replace(":", string.Empty);

            if (type == FileType.Directory && sb[sb.Length - 1] != '-')
                sb.Append('-');

            sb = sb.Append(".html");

            if (type != FileType.File && type != FileType.Directory && type != FileType.SourceFile)
            {
                sb = sb.Replace(" ", string.Empty);
                sb = sb.Replace("-g&lt;", "(");
                sb = sb.Replace("&lt;", "(");
                sb = sb.Replace("&gt;", ")");
            }

            return sb.ToString();
        }
开发者ID:wtfcolt,项目名称:game,代码行数:31,代码来源:Packer.cs

示例4: GetFilesFromDirectory

 public static void GetFilesFromDirectory(FileType type, ObservableCollection<CodeFile> collection, string directoryPath)
 {
     if (Directory.Exists(directoryPath))
     {
         string[] extensions = null;
         switch (type)
         {
             case FileType.All:
                 extensions = new string[] { ".cs", ".vb" };
                 break;
             case FileType.CS:
                 extensions = new string[] { ".cs" };
                 break;
             case FileType.VB:
                 extensions = new string[] { ".vb" };
                 break;
         }
         string[] files = Directory.GetFiles(directoryPath);
         foreach (string file in files)
         {
             if (!extensions.Contains<string>(Path.GetExtension(file)))
                 continue;
             CodeFile cFile = new CodeFile();
             PopulateCodeFile(cFile, file);
             collection.Add(cFile);
         }
     }
 }
开发者ID:flagmanAndrew,项目名称:FileBrowser_MVVM,代码行数:28,代码来源:FileLoaderHelper.cs

示例5: SaveFileAs

        public override void SaveFileAs(string fileName, FileType type)
        {
            // step 1: creation of a document-object
            iTextSharp.text.Document myDocument = new iTextSharp.text.Document(PageSize.A4.Rotate());
            try
            {
                // step 2:
                // Now create a writer that listens to this doucment and writes the document to desired Stream.
                PdfWriter.GetInstance(myDocument, new FileStream(fileName, FileMode.CreateNew));

                // step 3:  Open the document now using
                myDocument.Open();

                // step 4: Now add some contents to the document
                myDocument.Add(new iTextSharp.text.Paragraph(parsedFile.contentRaw));

            }
            catch (iTextSharp.text.DocumentException de)
            {
                Console.Error.WriteLine(de.Message);
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
            }
            myDocument.Close();
        }
开发者ID:sashaMilka,项目名称:MultiReader,代码行数:27,代码来源:PdfParser.cs

示例6: GetTypeList

 public static List<string> GetTypeList(FileType type) {
     short i = 0;
     switch (type) {
         case FileType.Compressed:
             i = 0;
             break;
         case FileType.Audio:
             i = 1;
             break;
         case FileType.Document:
             i = 2;
             break;
         case FileType.Image:
             i = 3;
             break;
         case FileType.SourceCode:
             i = 4;
             break;
         case FileType.Executable:
             i = 5;
             break;
         case FileType.Video:
             i = 6;
             break;
     }
     return TypesList[i];
 }
开发者ID:divyamamgai,项目名称:FileOrganizer,代码行数:27,代码来源:File+Organizer+File+Types.cs

示例7: getFileWithType

 public File getFileWithType( FileType filetype )
 {
     foreach ( File file in Files )
         if ( file.FileType == filetype )
             return file;
     return null;
 }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:7,代码来源:ContentOfOrderFile.cs

示例8: read_Templates_To_Memory

        public static List<Module> read_Templates_To_Memory(string inpath, FileType fileType)
        {
            int i = 0;
            string filepath = "";
            List<Module> modules = new List<Module>();

            try
            {
                foreach (char c in cset)
                {
                    for (i = 0; i < (1 << 10); i++)
                    {
                        filepath = string.Format("{0}{1}({2}).{3}", inpath, c, i, fileType);

                        if (!File.Exists(filepath)) { break; }
                        modules.Add(read_Template_From_Text_To_Memory(c, filepath));
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception("read_Templates_To_Memory:" + e.Message);
            }
            return modules;
        }
开发者ID:jiabailie,项目名称:Qunar,代码行数:25,代码来源:Template.cs

示例9: AddType

        public ActionResult AddType()
        {
            string error = "";
            CurtDevDataContext db = new CurtDevDataContext();

            #region Form Submission
            try {
                if (Request.Form.Count > 0) {

                    // Save form values
                    string fileType = (Request.Form["fileType"] != null) ? Request.Form["fileType"] : "";

                    // Validate the form fields
                    if (fileType.Length == 0) throw new Exception("Name is required.");

                    // Create the new customer and save
                    FileType new_type = new FileType {
                        fileType1 = fileType
                    };

                    db.FileTypes.InsertOnSubmit(new_type);
                    db.SubmitChanges();
                    return RedirectToAction("Types");
                }
            } catch (Exception e) {
                error = e.Message;
            }
            #endregion

            ViewBag.error = error;
            return View();
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:32,代码来源:FileExtController.cs

示例10: CreateCleaningStrategy

        protected static LightSpeedCleanStrategyBase CreateCleaningStrategy(FileType fileType)
        {
            switch (fileType)
            {
                case FileType.WordDocument:
                    return new LightSpeedWordCleaningStrategy();
                case FileType.WordDocumentX:
                case FileType.WordDocumentMacroX:
                case FileType.WordDocumentTemplateX:
                case FileType.WordDocumentMacroTemplateX:
                    return new LightSpeedWordXCleaningStrategy();

                case FileType.ExcelSheet:
                    return new LightSpeedExcelCleaningStrategy();
                case FileType.ExcelSheetX:
                case FileType.ExcelSheetMacroX:
                case FileType.ExcelSheetTemplateX:
                case FileType.ExcelSheetMacroTemplateX:
                    return new LightSpeedExcelXCleaningStrategy();

                case FileType.PowerPoint:
                    return new LightSpeedPowerPointCleaningStrategy();
                case FileType.PowerPointX:
                case FileType.PowerPointMacroX:
                case FileType.PowerPointTemplateX:
                case FileType.PowerPointMacroTemplateX:
				case FileType.PowerPointShowX:
				case FileType.PowerPointMacroShowX:
                    return new LightSpeedPowerPointXCleaningStrategy();

                default:
                    return null;
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:34,代码来源:LightSpeedCleanStrategyProxy.cs

示例11: DoTests

        protected void DoTests(FileHeader header, FileType expectedFileType, string expectedExtension)
        {
            string fileTypeErrorMessage;
               switch (expectedFileType)
               {
              default:
              case FileType.Other:
                 fileTypeErrorMessage = "Unknown file type";
                 break;
              case FileType.Image:
                 fileTypeErrorMessage = "Should be an image file";
                 break;
              case FileType.Video:
                 fileTypeErrorMessage = "Should be a video file";
                 break;
              case FileType.Audio:
                 fileTypeErrorMessage = "Should be an audio file";
                 break;
              case FileType.Swf:
                 fileTypeErrorMessage = "Should be a flash file";
                 break;
               }

               var extensionErrorMessage = "File format should be " + expectedExtension;

               Assert.NotNull(header, "File header returned null");
               Assert.AreEqual(header.Type, expectedFileType, fileTypeErrorMessage);
               Assert.AreEqual(header.Extension, expectedExtension, extensionErrorMessage);
        }
开发者ID:gokceyucel,项目名称:MimeBank,代码行数:29,代码来源:BaseTest.cs

示例12: CodeCoverageStringTextSource

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="source"></param>
        /// <param name="filePath"></param>
        public CodeCoverageStringTextSource(string source, string filePath)
        {
            _fileFound = source != null;

            if (!string.IsNullOrWhiteSpace (filePath)) {
                _filePath = filePath;
                if (_filePath.IndexOfAny(Path.GetInvalidPathChars()) < 0
                    && Path.GetExtension(_filePath).ToLowerInvariant() == ".cs" ) {
                    _fileType = FileType.CSharp;
                }
                if (_fileFound) {
                    try { 
                        _fileTime = System.IO.File.GetLastWriteTimeUtc (this._filePath); 
                    } catch (Exception e) {
                        e.InformUser();
                    }
                }

            }

            _textSource = string.IsNullOrEmpty(source) ? string.Empty : source;

            if (_textSource != string.Empty) {
                _lines = InitLines ();
            }

        }
开发者ID:AtwooTM,项目名称:opencover,代码行数:32,代码来源:CodeCoverageStringTextSource.cs

示例13: Paste

 public Paste(string directory,FileType fileType)
 {
     InitializeComponent();
     // add / to directory name if it doesn't already end in one
     this.directory = directory.Last()=='\\'?directory:directory+"\\";
     this.fileType = fileType;
 }
开发者ID:kashwaa,项目名称:PasteAsFile,代码行数:7,代码来源:Paste.cs

示例14: CreateFile

        public WikiFile CreateFile(string fileName, Guid listingVersionGuid, Guid vendorGuid, HttpPostedFile file, FileType fileType, List<UmbracoVersion> v, string dotNetVersion, bool mediumTrust)
        {
            // we have to convert to the uWiki UmbracoVersion :(

            List<UmbracoVersion> vers = new List<UmbracoVersion>();

            foreach (var ver in v)
            {
                vers.Add(UmbracoVersion.AvailableVersions()[ver.Version]);
            }

            //Create the Wiki File
            var uWikiFile = WikiFile.Create(fileName, listingVersionGuid, vendorGuid, file, GetFileTypeAsString(fileType), vers);
            //return the IMediaFile

            //Convert to Deli Media file
            var MediaFile = GetFileById(uWikiFile.Id);

            // If upload is package, extract the package XML manifest and check the version number + type [LK:[email protected]]
            if (fileType == FileType.package)
            {
                var minimumUmbracoVersion = GetMinimumUmbracoVersion(MediaFile);
                if (!string.IsNullOrWhiteSpace(minimumUmbracoVersion))
                {
                    MediaFile.Versions = new List<UmbracoVersion>() { new UmbracoVersion { Version = minimumUmbracoVersion } };
                }
            }

            MediaFile.DotNetVersion = dotNetVersion;
            SaveOrUpdate(MediaFile);
            return MediaFile;
        }
开发者ID:ClaytonWang,项目名称:OurUmbraco,代码行数:32,代码来源:MediaProvider.cs

示例15: Media

 public Media(string title, string length, string path, FileType fileType)
 {
     Title = title;
     Duree = length;
     Path = path;
     Type = fileType;
 }
开发者ID:Pr0xY,项目名称:mywmp,代码行数:7,代码来源:Media.cs


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