當前位置: 首頁>>代碼示例>>C#>>正文


C# File.exists方法代碼示例

本文整理匯總了C#中System.IO.File.exists方法的典型用法代碼示例。如果您正苦於以下問題:C# File.exists方法的具體用法?C# File.exists怎麽用?C# File.exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.File的用法示例。


在下文中一共展示了File.exists方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: inform

	  // TODO: this should use inputstreams from the loader, not File!
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void inform(org.apache.lucene.analysis.util.ResourceLoader loader) throws java.io.IOException
	  public virtual void inform(ResourceLoader loader)
	  {
		if (mapping != null)
		{
		  IList<string> wlist = null;
		  File mappingFile = new File(mapping);
		  if (mappingFile.exists())
		  {
			wlist = getLines(loader, mapping);
		  }
		  else
		  {
			IList<string> files = splitFileNames(mapping);
			wlist = new List<>();
			foreach (string file in files)
			{
			  IList<string> lines = getLines(loader, file.Trim());
			  wlist.AddRange(lines);
			}
		  }
		  NormalizeCharMap.Builder builder = new NormalizeCharMap.Builder();
		  parseRules(wlist, builder);
		  normMap = builder.build();
		  if (normMap.map == null)
		  {
			// if the inner FST is null, it means it accepts nothing (e.g. the file is empty)
			// so just set the whole map to null
			normMap = null;
		  }
		}
	  }
開發者ID:WakeflyCBass,項目名稱:lucenenet,代碼行數:34,代碼來源:MappingCharFilterFactory.cs

示例2: FileIDMigrator

  public FileIDMigrator(File dataFile, long minReloadIntervalMS) {
    longToString = new FastByIDMap<String>(100);
    this.dataFile = Preconditions.checkNotNull(dataFile);
    if (!dataFile.exists() || dataFile.isDirectory()) {
      throw new FileNotFoundException(dataFile.toString());
    }

    log.info("Creating FileReadonlyIDMigrator for file {}", dataFile);

    this.reloadLock = new ReentrantLock();
    this.lastModified = dataFile.lastModified();
    this.minReloadIntervalMS = minReloadIntervalMS;

    reload();
  }
開發者ID:yan6pz,項目名稱:MovieRecommendation,代碼行數:15,代碼來源:FileIDMigrator.cs

示例3: ProcessFile

        private static void ProcessFile(File effDocFile, File outFile)
        {
            if (!effDocFile.exists())
            {
                throw new RuntimeException("file '" + effDocFile.GetAbsolutePath() + "' does not exist");
            }
            OutputStream os;
            try
            {
                os = new FileOutputStream(outFile);
            }
            catch (FileNotFoundException e)
            {
                throw new RuntimeException(e);
            }
            os = new SimpleAsciiOutputStream(os);
            PrintStream ps;
            try
            {
                ps = new PrintStream(os, true, "UTF-8");
            }
            catch (UnsupportedEncodingException e)
            {
                throw new RuntimeException(e);
            }

            outputLicenseHeader(ps);
            Type genClass = typeof(ExcelFileFormatDocFunctionExtractor);
            ps.println("# Created by (" + genClass.Name + ")");
            // identify the source file
            ps.print("# from source file '" + SOURCE_DOC_FILE_NAME + "'");
            ps.println(" (size=" + effDocFile.Length + ", md5=" + GetFileMD5(effDocFile) + ")");
            ps.println("#");
            ps.println("#Columns: (index, name, minParams, maxParams, returnClass, paramClasses, isVolatile, hasFootnote )");
            ps.println("");
            try
            {
                ZipFile zf = new ZipFile(effDocFile);
                InputStream is1 = zf.GetInputStream(zf.GetEntry("content.xml"));
                extractFunctionData(new FunctionDataCollector(ps), is1);
                zf.Close();
            }
            catch (ZipException e)
            {
                throw new RuntimeException(e);
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }
            ps.Close();

            String canonicalOutputFileName;
            try
            {
                canonicalOutputFileName = outFile.GetCanonicalPath();
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }
            Console.WriteLine("Successfully output to '" + canonicalOutputFileName + "'");
        }
開發者ID:ctddjyds,項目名稱:npoi,代碼行數:63,代碼來源:ExcelFileFormatDocFunctionExtractor.cs

示例4: loadModelFromZip

 public static LexicalizedParser loadModelFromZip(String zipFilename,
                                                  String modelName) {
   LexicalizedParser parser = null;
   try {
     File file = new File(zipFilename);
     if (file.exists()) {
       ZipFile zin = new ZipFile(file);
       ZipEntry zentry = zin.getEntry(modelName);
       if (zentry != null) {
         InputStream in = zin.getInputStream(zentry);
         // gunzip it if necessary
         if (modelName.endsWith(".gz")) {
           in = new GZIPInputStream(in);
         }
         ObjectInputStream ois = new ObjectInputStream(in);
         parser = loadModel(ois);
         ois.close();
         in.close();
       }
       zin.close();
     } else {
       throw new FileNotFoundException("Could not find " + modelName +
                                       " inside " + zipFilename);
     }
   } catch (IOException e) {
開發者ID:gblosser,項目名稱:OpenNlp,代碼行數:25,代碼來源:LexicalizedParser.cs


注:本文中的System.IO.File.exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。