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


C# FileInfo.ToLower方法代码示例

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


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

示例1: ExportData

        public static void ExportData(this PrintableControlLink control, string path)
        {
            string fileExtenstion = new FileInfo(path).Extension;

            switch (fileExtenstion.ToLower())
            {
                case ".xls":
                    control.ExportToXls(path);
                    break;
                case ".xlsx":
                    control.ExportToXlsx(path, new XlsxExportOptions(TextExportMode.Text, true, true));
                    break;
                case ".rtf":
                    control.ExportToRtf(path);
                    break;
                case ".pdf":
                    control.ExportToPdf(path);
                    break;
                case ".html":
                    control.ExportToHtml(path);
                    break;
                case ".mht":
                    control.ExportToMht(path);
                    break;
                default:
                    break;
            }
        }
开发者ID:JPVenson,项目名称:svnproj,代码行数:28,代码来源:DevExGridExport.cs

示例2: CreateFromFileName

 public static ImageType CreateFromFileName(string fileName)
 {
     string fileExtension = new FileInfo(fileName).Extension;
     switch (fileExtension.ToLower())
     {
         case ".png":
             return ImageType.Png;
         case ".gif":
             return ImageType.Gif;
         case ".jpg":
         case ".jpeg":
             return ImageType.Jpeg;
     }
     throw new NotSupportedException("Image type " + fileExtension + " is not supported.");
 }
开发者ID:alex687,项目名称:SoftUni-Homeworks,代码行数:15,代码来源:ImageType.cs

示例3: GenerateVirtualFlac

        private static void GenerateVirtualFlac(string file)
        {
            Init("Creating...");

            string fileName = new FileInfo(file).Name;

            string aplDirectory = Directory.GetParent(file).FullName;
            string[] files = Directory.GetFiles(aplDirectory, "*.apl");
            foreach (string f in files)
            {
                AplFile apl = new AplFile(f);
                if (apl.ImageFile.ToLower() != fileName.ToLower())
                {
                    Console.WriteLine(apl.ImageFile);
                    Console.WriteLine(fileName);

                    throw new VfgException("Invalid apl/ image combination");
                }
                aplFiles_.Add(apl);
            }

            new VirtualFlacCreator(file, fileName, aplFiles_.ToArray());
            Done();
        }
开发者ID:LastContrarian,项目名称:flacfs,代码行数:24,代码来源:Program.cs

示例4: GetValidDirectoryPath

        /// <summary> Returns true if the directory path (not including a filename) is valid.
        /// 
        /// </summary>
        /// <param name="context">The validation context.</param>
        /// <param name="input">The directory to validate.</param>        
        /// <returns>Boolean value indicating whether the data is valid.</returns>
        /// <seealso cref="Owasp.Esapi.Interfaces.IValidator.GetValidDirectoryPath(string, string, bool)">
        /// </seealso>
        public string GetValidDirectoryPath(string context, string input, bool allowNull)
        {
            String canonical = "";
              try {
            if (IsEmpty(input)) {
              if (allowNull) return null;
              throw new ValidationException(context + " is required", "(" + context + ") input is required");
            }

            canonical = Esapi.Encoder().Canonicalize(input);

            // do basic validation
            Regex directoryNamePattern = ((SecurityConfiguration)Esapi.SecurityConfiguration()).GetValidationPattern("DirectoryName");
            if (!directoryNamePattern.Match(canonical).Success) {
              throw new ValidationException(context + " is an invalid directory name", "Attempt to use a directory name (" + canonical + ") that violates the global rule in ESAPI.properties (" + directoryNamePattern.ToString() + ")");
            }

            // get the canonical path without the drive letter if present
            String cpath = new FileInfo(canonical).Name.Replace("\\\\", "/");
            String temp = cpath.ToLower();
            if (temp.Length >= 2 && temp[0] >= 'a' && temp[0] <= 'z' && temp[1] == ':') {
              cpath = cpath.Substring(2);
            }

            // prepare the input without the drive letter if present
            String escaped = canonical.Replace("\\\\", "/");
            temp = escaped.ToLower();
            if (temp.Length >= 2 && temp[0] >= 'a' && temp[0] <= 'z' && temp[1] == ':') {
              escaped = escaped.Substring(2);
            }

            // the path is valid if the input matches the canonical path
            if (!escaped.Equals(cpath.ToLower())) {
              throw new ValidationException(context + " is an invalid directory name", "The input path does not match the canonical path (" + canonical + ")");
            }
              } catch (IOException e) {
            throw new ValidationException(context + " is an invalid directory name", "Attempt to use a directory name (" + canonical + ") that does not exist");
              } catch (EncodingException ee) {
            throw new IntrusionException(context + " is an invalid directory name", "Exception during directory validation", ee);
              }
              return canonical;
        }
开发者ID:Effzz,项目名称:owasp-esapi-classicasp,代码行数:50,代码来源:Validator.cs

示例5: MakeRelativeUrl

        /// <summary>
        /// This relative URL will be the key in the $templateCache entry.
        /// </summary>
        /// <param name="file"></param>
        /// <param name="serverRootPath"></param>
        /// <returns></returns>
        private string MakeRelativeUrl(String file, String serverRootPath)
        {
            //Make the path lowercase, but preserve casing for the file (apparently, that's how angular makes keys)
            var dir = new FileInfo(file).DirectoryName;
            file = file.Replace(dir, dir.ToLower());

            return file.Substring(serverRootPath.Length).Replace("\\", "/");
            //return file.Substring(serverRootPath.Length - templateRoot.Length).Replace("\\", "/");
        }
开发者ID:joakimjm,项目名称:eziou,代码行数:15,代码来源:NgTemplateCacheBuilder.cs

示例6: CreateNode

        static void CreateNode(string[] folder)
        {
            string dirName = new FileInfo(folder[0]).Name;
            dirName = dirName.ToUpper();
            for (int c = 0; c < dirName.Length; c++)
            {
                if (c == 4)
                    break;
                nodes[numNodesDone].type = nodes[numNodesDone].type + dirName[c];

            }
            nodes[numNodesDone].filenameOffset = (uint)stringTable.Length;
            stringTable = stringTable + dirName.ToLower() + (char)0x00;
            string[] numFiles = Directory.GetFileSystemEntries(folder[0]);
            nodes[numNodesDone].numFileEntries = (ushort)(numFiles.Length + 2);
            nodes[numNodesDone].firstFileEntryOffset = (uint)totalNumFilesAdded;

            dirName = new FileInfo(folder[0]).Name;
            nodes[numNodesDone].foldernameHash = Hash(dirName);

            numNodesDone++;
        }
开发者ID:Sage-of-Mirrors,项目名称:TheWindWaker_Text_Editor,代码行数:22,代码来源:RARCPacker_Source.cs

示例7: ConverterTXT

        public ConverterTXT(string arquivo)
        {
            Auxiliar oAux = new Auxiliar();

            NFe.ConvertTxt.ConversaoTXT oUniTxtToXml = new NFe.ConvertTxt.ConversaoTXT();

            string pasta = new FileInfo(arquivo).DirectoryName;
            pasta = pasta.Substring(0, pasta.Length - 5); //Retirar a pasta \Temp do final - Wandrey 03/08/2011

            string ccMessage = string.Empty;
            string ccExtension = "-nfe.err";

            try
            {
                int emp = Empresas.FindEmpresaByThread();

                ///
                /// exclui o arquivo de erro
                /// 
                Functions.DeletarArquivo(Empresas.Configuracoes[emp].PastaXmlRetorno + "\\" + Path.GetFileName(Functions.ExtrairNomeArq(arquivo, Propriedade.ExtEnvio.Nfe_TXT) + ccExtension));
                Functions.DeletarArquivo(Empresas.Configuracoes[emp].PastaXmlRetorno + "\\" + Path.GetFileName(Functions.ExtrairNomeArq(arquivo, Propriedade.ExtEnvio.Nfe_TXT) + "-nfe-ret.xml"));
                Functions.DeletarArquivo(Empresas.Configuracoes[emp].PastaXmlErro + "\\" + Path.GetFileName(arquivo));
                ///
                /// exclui o arquivo TXT original
                /// 
                Functions.DeletarArquivo(Empresas.Configuracoes[emp].PastaXmlRetorno + "\\" + Path.GetFileNameWithoutExtension(arquivo) + "-orig.txt");

                ///
                /// processa a conversão
                /// 
                oUniTxtToXml.Converter(arquivo, pasta);//Empresas.Configuracoes[emp].PastaRetorno);

                //Deu tudo certo com a conversão?
                if (string.IsNullOrEmpty(oUniTxtToXml.cMensagemErro))
                {
                    ///
                    /// danasa 8-2009
                    /// 
                    if (oUniTxtToXml.cRetorno.Count == 0)
                    {
                        ccMessage = "cStat=02\r\n" +
                            "xMotivo=Falha na conversão. Sem informações para converter o arquivo texto";

                        oAux.MoveArqErro(arquivo, ".txt");
                    }
                    else
                    {
                        //
                        // salva o arquivo texto original
                        //
                        if (pasta.ToLower().Equals(Empresas.Configuracoes[emp].PastaXmlEnvio.ToLower()) || pasta.ToLower().Equals(Empresas.Configuracoes[emp].PastaValidar.ToLower()))
                        {
                            FileInfo ArqOrig = new FileInfo(arquivo);

                            string vvNomeArquivoDestino = Empresas.Configuracoes[emp].PastaXmlRetorno + "\\" + Path.GetFileNameWithoutExtension(arquivo) + "-orig.txt";
                            ArqOrig.MoveTo(vvNomeArquivoDestino);
                        }
                        ccExtension = "-nfe.txt";
                        ccMessage = "cStat=01\r\n" +
                            "xMotivo=Convertido com sucesso. Foi(ram) convertida(s) " + oUniTxtToXml.cRetorno.Count.ToString() + " nota(s) fiscal(is)";

                        foreach (NFe.ConvertTxt.txtTOxmlClassRetorno txtClass in oUniTxtToXml.cRetorno)
                        {
                            ///
                            /// monta o texto que será gravado no arquivo de aviso ao ERP
                            /// 
                            ccMessage += Environment.NewLine +
                                    "Nota fiscal: " + txtClass.NotaFiscal.ToString("000000000") +
                                    " Série: " + txtClass.Serie.ToString("000") +
                                    " - ChaveNFe: " + txtClass.ChaveNFe;

                            // move o arquivo XML criado na pasta Envio\Convertidos para a pasta Envio
                            // ou
                            // move o arquivo XML criado na pasta Validar\Convertidos para a pasta Validar
                            string nomeArquivoDestino = Path.Combine(pasta, Path.GetFileName(txtClass.XMLFileName));
                            Functions.Move(txtClass.XMLFileName, nomeArquivoDestino);

                            Functions.DeletarArquivo(Empresas.Configuracoes[emp].PastaXmlErro + "\\" + txtClass.ChaveNFe + Propriedade.ExtEnvio.Nfe);
                        }
                    }
                }
                else
                {
                    ///
                    /// danasa 8-2009
                    /// 
                    ccMessage = "cStat=99\r\n" +
                        "xMotivo=Falha na conversão\r\n" +
                        "MensagemErro=" + oUniTxtToXml.cMensagemErro;
                }
            }
            catch (Exception ex)
            {
                ccMessage = ex.Message;
                ccExtension = "-nfe.err";
            }

            if (!string.IsNullOrEmpty(ccMessage))
            {
                oAux.MoveArqErro(arquivo, ".txt");
//.........这里部分代码省略.........
开发者ID:akretion,项目名称:uninfe,代码行数:101,代码来源:ConverterTXT.cs

示例8: DownloadFile

        public void DownloadFile(documento doc, Forms.MyAccount form)
        {
            Thread t = new Thread(() => {
                if (!String.IsNullOrEmpty(doc.hash))
                {
                    if (String.IsNullOrEmpty(doc.name))
                    {
                        doc.name = "Sem nome";
                    }

                    if (AbcDoc != null)
                    {
                        String oldName = string.Empty;

                        try
                        {
                            //recebe o arquivo do abcdoc
                            oldName = AbcDoc.receberArquivo(doc.hash, Dir.TempDirectory);
                        }
                        catch
                        {
                            oldName = string.Empty;
                        }

                        if (!String.IsNullOrEmpty(oldName))
                        {
                            String newFileName = Util.User.GetDirDownload() + doc.name;
                            String newFileExtension = new FileInfo(oldName).Extension;
                            String newName = newFileName + newFileExtension;

                            if (File.Exists(newName))
                            {
                                //cria um versionamento pro arquivo, pois ele ja existe
                                Int32 count = 1;

                                while (File.Exists(newFileName + "(" + count.ToString() + ")" + newFileExtension))
                                {
                                    count++;
                                }

                                newName = newFileName + "(" + count.ToString() + ")" + newFileExtension;
                            }

                            if (File.Exists(oldName) && !File.Exists(newName))
                            {
                                File.Move(oldName, newName);

                                if (File.Exists(newName))
                                {
                                    if (Addin.CurrentAccount.openDocument)
                                    {
                                        //faz a uniao das extensoes de documentos, planilhas e apresentacoes
                                        var union =
                                            Forms.MyAccount.wextensions
                                            .Concat(Forms.MyAccount.eextensions)
                                            .Concat(Forms.MyAccount.pextensions)
                                            .Concat(Forms.MyAccount.iextensions);

                                        if(union.Any(ext => ext.ToLower().Equals(newFileExtension.ToLower())))
                                        {
                                            Process.Start(newName);
                                        }
                                    }
                                }

                                try
                                {
                                    File.Delete(oldName);
                                }
                                catch
                                {
                                }
                            }
                            else
                            {
                                MessageBox.Show("Não foi possível completar o download. O arquivo é inválido.");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Não foi possível completar o download. Verifique sua conexão com a internet.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Não foi possível completar o download. Verifique sua conexão com a internet.");
                    }
                }
                else
                {
                    MessageBox.Show("Não foi possível completar o download. O documento selecionado é inválido.");
                }

                form.Invoke((MethodInvoker)(() => form.buttonDownloadDocument.Enabled = true));
            });

            t.Start();
        }
开发者ID:nikkw,项目名称:W2C,代码行数:98,代码来源:DownloadFile.cs

示例9: InitIcons

 private void InitIcons(string text,string filename,string iconname,int index)
 {
     ListViewItem lvi = listView1.Items.Add(text);
     lvi.Tag = new FileInfo(filename).FullName;
     string ext = new FileInfo(filename).Extension;
     //MessageBox.Show(ext);
     Image ico = InitExtIcon(ext, iconname,index);
     if (ico != null && imageList2.Images.Keys.IndexOf(ext.ToLower() != ".exe" ? ext.Substring(1) : (iconname + "_" + index.ToString())) == -1)
     {
         imageList2.Images.Add(ext.ToLower() != ".exe" ? ext.Substring(1) : (iconname+"_"+index.ToString()), ico);
     }
     if (ext == "" || imageList2.Images.Keys.IndexOf(ext.ToLower() != ".exe" ? ext.Substring(1) : (iconname + "_" + index.ToString())) == -1)
     {
         lvi.ImageKey = "file";
     }
     else
     {
         lvi.ImageKey = ext.ToLower() != ".exe" ? ext.Substring(1) : (iconname + "_" + index.ToString());
     }
     listView1.DoubleClick += listView1_DoubleClick;
 }
开发者ID:WeslieRoco,项目名称:Roco_Shell,代码行数:21,代码来源:Form1.cs

示例10: Encrypt

        /// <summary>
        ///     Encrypts specified filepath
        /// </summary>
        /// <param name="filepath">the filepath to encrypt, file must be in the same directory as the PARAM.PFD</param>
        /// <returns>true if file is succesfully encrypted</returns>
        public bool Encrypt(string filepath)
        {
            try
            {
                if (!File.Exists(filepath))
                {
                    DoProgress(filepath + " Does not exist!", MessageType.Error);
                    return false;
                }
                string name = new FileInfo(filepath).Name;
                if (!EntryExists(name))
                {
                    DoProgress("There is no \"" + name + "\" inside the PARAM.PFD Entries!", MessageType.Error);
                    return false;
                }
                DoProgress("Initializing file stream..", MessageType.Info);
                byte[] data = null;
                using (FileStream fs = File.Open(filepath, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
                {
                    for (int i = 0; i < PFDEntries.entries.Count; i++)
                    {
                        if (PFDEntries.entries[i].file_name.ToLower() == name.ToLower())
                        {
                            PFDEntry t = PFDEntries.entries[i];
                            t.file_size = (ulong) fs.Length;
                            PFDEntries.entries[i] = t;
                            break;
                        }
                    }

                    data = Encrypt(fs, name);
                    //DoProgress("Rehashing PARAM.PFD..", MessageType.Info);
                    //bool x = ValidEntryHash(fs, name, true) && ValidFileCID(true) && ValidDHKCID2(true) && ValidBottomHash(true);
                    fs.Dispose();
                }
                if (data == null)
                    return false;
                DoProgress("Writing Encrypted data to : " + filepath, MessageType.Info);
                File.WriteAllBytes(filepath, data);
                DoProgress(name + " is succesfully encrypted", MessageType.Info);
                return true;
            }
            catch (Exception ex)
            {
                DoProgress(ex.Message, MessageType.Error);
                return false;
            }
        }
开发者ID:jtrent238,项目名称:Minecraft-PS3-Save-Tool,代码行数:53,代码来源:Param_PFD.cs

示例11: GetSolutionFileFullName

 public static string GetSolutionFileFullName(string fullPath)
 {
     string rootDir = new FileInfo(_dte.Solution.FullName).Directory.FullName;
     return fullPath.ToLower().Replace(rootDir.ToLower() + "\\", "");
 }
开发者ID:dsueltenfuss,项目名称:vstools,代码行数:5,代码来源:SetupHelpers.cs

示例12: EnableBuildTimeConfigTransformations

        public async Task<bool> EnableBuildTimeConfigTransformations()
        {
            if (!CanEnableBuildTimeTransformations) return false;

            var dialogResult = MessageBox.Show(_ownerWindow,
                "Are you sure you want to enable build-time transformations?",
                "Enable build-time transformations? (Confirmation)", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (dialogResult == DialogResult.Cancel) return false;

            _logger.LogInfo("Enabling config transformations.");
            Environment.CurrentDirectory = Project.GetDirectory();

            if (!Project.Saved) Project.Save();

            // 1. determine if web.config vs app.config
            var originalConfigFile = Project.GetConfigFile();
            if (string.IsNullOrEmpty(ProjectProperties.AppCfgType))
            {
                Guid? projectKind = !string.IsNullOrEmpty(Project.Kind) ? Guid.Parse(Project.Kind) : (Guid?)null;
                var webProjectTypes = new[]
                    {
                        ProjectTypes.WebSite,
                        ProjectTypes.AspNetMvc10,
                        ProjectTypes.AspNetMvc20,
                        ProjectTypes.AspNetMvc30,
                        ProjectTypes.AspNetMvc40,
                        ProjectTypes.WebApplication
                    };
                var projectTypes = Project.GetProjectTypeGuids().Split(';').Select(Guid.Parse);
                if (projectKind.HasValue && (webProjectTypes.Contains(projectKind.Value) ||
                    projectTypes.Any(t => webProjectTypes.Contains(t))))
                {
                    ProjectProperties.AppCfgType = "Web";
                }
                else ProjectProperties.AppCfgType = "App";
            }
            if (string.IsNullOrEmpty(originalConfigFile))
            {
                originalConfigFile = Path.Combine(Project.GetDirectory(), ProjectProperties.AppCfgType + ".config");
            }
            var originalConfigFileName = new FileInfo(originalConfigFile).Name;
            
            // 2. determine if need to use inline transformations or bin transformations
            //  >> if web or clickonce, inline is mandatory
            var inlineTransformations = ProjectProperties.InlineTransformations ?? originalConfigFileName.ToLower() == "web.config" ? true : false;
            if (!inlineTransformations && !string.IsNullOrEmpty(ProjectProperties.GetPropertyValue("PublishUrl")))
                inlineTransformations = true;
            ProjectProperties.InlineTransformations = inlineTransformations;

            bool prepresult;

            // in nested:
            // 3. if inline transformations, determine config folder
            // 4. if inline transformations, move and/or create web.config and related transforms to config folder
            // 4b. update project XML for moved files
            // 4c. inject warning xml to base
            if (inlineTransformations) prepresult = await PrepEnableInlineBuildTimeConfigTransformations();

            // create missing web.config and related transforms to config folder
            // also make sure that the project has the proper task added (as with the case of app.config non-clickonce)
            else prepresult = await PrepEnableBuildTimeConfigTransformationsForBin();

            if (prepresult == false) return false;
            ProjectProperties.BuildTimeTransformsEnabled = true;

            // 5. inject target definition to project
            /* web app (this should already be in the project so don't add it):
             * <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" 
                    Condition="'$(VSToolsPath)' != ''" /> 
             */
            /* non-web app:
             *  <UsingTask TaskName="TransformXml"
                   AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll"/>
             */
            EnsureTransformXmlTaskInProject();

            // ensure target is invoked on build
            // >> two parts for this:
            // >> 6) add a target that invokes the TransformXml task
            EnsureTransformXmlTarget();

            // >> 7) ensure that the target gets invoked (either with Before/AfterBuild or DefaultTargets)



            // 8. save changes and reload project
            await Project.SaveProjectRoot();

            return true;
        }
开发者ID:sayedihashimi,项目名称:FastKoala,代码行数:90,代码来源:BuildTimeTransformationsEnabler.cs


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