當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。