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


C# String.EndsWith方法代码示例

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


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

示例1: Export

        /// <summary>
        /// Экспортирует массив данных в XLSX формат с учетом выбранной локали
        /// </summary>
        /// <param name="path">Путь к файлу, в который нужно сохранить данные</param>
        /// <param name="localisation">Локализация</param>
        /// <returns>Успешное завершение операции</returns>
        public override bool Export(String path, Localisation localisation)
        {
            try
            {
                if (!path.EndsWith(".xlsx"))
                    path += ".xlsx";

                log.Info(String.Format("Export to .xlsx file to: {0}", path));
                var timer = new Stopwatch();
                timer.Start();
                var file = new FileInfo(path);
                using (var pck = new ExcelPackage(file))
                {
                    ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Sheet1");
                    ws.Cells["A1"].LoadFromDataTable(dataTable, true);
                    ws.Cells.AutoFitColumns();
                    pck.Save();
                }

                timer.Stop();
                log.Info(String.Format("Export complete! Elapsed time: {0} ms", timer.Elapsed.Milliseconds));
                return true;
            }
            catch (Exception ex)
            {
                log.Error("Can't export to .xlsx file!", ex);
                return false;
            }
        }
开发者ID:nozdrenkov,项目名称:CSVConverter,代码行数:35,代码来源:XLSXConverter.cs

示例2: removeLastSlash

        public static String removeLastSlash(String path)
        {
            if (path.EndsWith("/") || path.EndsWith("\\") )
                return path.Substring(1);

            return path;
        }
开发者ID:rrmartins,项目名称:rhodes,代码行数:7,代码来源:RhoFilePath.cs

示例3: GetFileStaticRelativePath

        public static String GetFileStaticRelativePath(String fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                return string.Empty;
            }

            if (fileName.EndsWith(".js"))
            {
                //Attention: Only for ResourceBundleControl
                return VirtualPathUtility.ToAbsolute("~/products/projects/js/" + fileName);
            }

            if (fileName.EndsWith(".png"))
            {
                return WebPath.GetPath("/Products/Projects/App_Themes/Default/Images/" + fileName);
            }

            if (fileName.EndsWith(".css"))
            {
                //Attention: Only for ResourceBundleControl
                return VirtualPathUtility.ToAbsolute("~/products/projects/app_themes/default/css/" + fileName);
            }

            return string.Empty;
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:26,代码来源:PathProvider.cs

示例4: startExplorerProcess

 /*
  * Starts a new explorer process with passed arguments.
  *
  * Added 2007-05-01 by T.Norad
  * 2009-02-27 Nochbaer: Edited to select the file in the explorer window and call the standard shell on mono
  */
 public static void startExplorerProcess(String path, String filename)
 {
     if (!UtilitiesForMono.IsRunningOnMono)
     {
         string arguments;
         if (filename.Length > 0)
         {
             string secondStringArgument = "";
             if (!path.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
             {
                 secondStringArgument =  System.IO.Path.DirectorySeparatorChar.ToString();
             }
             arguments = String.Format("/e,/select,\"{0}{1}{2}\"", path,secondStringArgument, filename);
         }
         else
         {
             arguments = String.Format("/e,{0}", path);
         }
         ProcessStarter.startProcess(EXLORER_PROCESS, arguments);
     }
     else
     {
         if (!path.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
         {
             path = path + System.IO.Path.DirectorySeparatorChar.ToString();
             ProcessStarter.startProcess(path);
         }
     }
 }
开发者ID:Steeslice,项目名称:StealthNet-Alt,代码行数:35,代码来源:ProcessStarter.cs

示例5: makeAll

		public static void makeAll(String baseDirectory, String version)
		{
			//make base directory
			if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
			{
				baseDirectory = baseDirectory + "/";
			}
			FileInfo targetDir =
				SourceGenerator.makeDirectory(baseDirectory + PackageManager.GetVersionPackagePath(version) + "EventMapping");

			//get list of data types
			OleDbConnection conn = NormativeDatabase.Instance.Connection;
			String sql =
				"SELECT * from HL7EventMessageTypes inner join HL7Versions on HL7EventMessageTypes.version_id = HL7Versions.version_id where HL7Versions.hl7_version = '" +
				version + "'";
			OleDbCommand temp_OleDbCommand = new OleDbCommand();
			temp_OleDbCommand.Connection = conn;
			temp_OleDbCommand.CommandText = sql;
			OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();


			using (StreamWriter sw = new StreamWriter(targetDir.FullName + @"\EventMap.properties", false))
			{
				sw.WriteLine("#event -> structure map for " + version);
				while (rs.Read())
				{
					string messageType = string.Format("{0}_{1}", rs["message_typ_snd"], rs["event_code"]);
					string structure = (string) rs["message_structure_snd"];

					sw.WriteLine(string.Format("{0} {1}", messageType, structure));
				}
			}
		}
开发者ID:liddictm,项目名称:nHapi,代码行数:33,代码来源:EventMappingGenerator.cs

示例6: writeGroup

		/// <summary> Creates source code for a Group and returns a GroupDef object that 
		/// describes the Group's name, optionality, repeatability.  The source 
		/// code is written under the given directory.
		/// The structures list may contain [] and {} pairs representing 
		/// nested groups and their optionality and repeastability.  In these cases
		/// this method is called recursively.
		/// If the given structures list begins and ends with repetition and/or 
		/// optionality markers the repetition and optionality of the returned 
		/// GroupDef are set accordingly.  
		/// <param name="structures">a list of the structures that comprise this group - must 
		/// be at least 2 long
		/// </param>
		/// <param name="groupName">The group name</param>
		/// <param name="version">The version of message</param>
		/// <param name="baseDirectory">the directory to which files should be written
		/// </param>
		/// <param name="message">the message to which this group belongs
		/// </param>
		/// <throws>  HL7Exception if the repetition and optionality markers are not  </throws>
		/// </summary>
		public static GroupDef writeGroup(IStructureDef[] structures, String groupName, String baseDirectory, String version,
			String message)
		{
			//make base directory
			if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
			{
				baseDirectory = baseDirectory + "/";
			}
			FileInfo targetDir =
				SourceGenerator.makeDirectory(baseDirectory + PackageManager.GetVersionPackagePath(version) + "Group");

			// some group names are troublesome and have "/" which will cause problems when writing files
			groupName = groupName.Replace("/", "_");
			GroupDef group = getGroupDef(structures, groupName, baseDirectory, version, message);

			using (StreamWriter out_Renamed = new StreamWriter(targetDir.FullName + @"\" + group.Name + ".cs"))
			{
				out_Renamed.Write(makePreamble(group, version));
				out_Renamed.Write(makeConstructor(group, version));

				IStructureDef[] shallow = group.Structures;
				for (int i = 0; i < shallow.Length; i++)
				{
					out_Renamed.Write(makeAccessor(group, i));
				}
				out_Renamed.Write("}\r\n"); //Closing class
				out_Renamed.Write("}\r\n"); //Closing namespace
			}
			return group;
		}
开发者ID:liddictm,项目名称:nHapi,代码行数:50,代码来源:GroupGenerator.cs

示例7: MakeRelativePath

        /// <summary>
        /// Creates a relative path from one file or folder to another.
        /// </summary>
        /// <param name="fromPath">Contains the directory that defines the start of the relative path.</param>
        /// <param name="fromIs">Is the fromPath a File or a Folder</param>
        /// <param name="toPath">Contains the path that defines the endpoint of the relative path.</param>
        /// <param name="toIs">Is the toPath a File or a Folder</param>
        /// <returns>The relative path from the start directory to the end path or <c>toPath</c> if the paths are not related.</returns>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="UriFormatException"></exception>
        /// <exception cref="InvalidOperationException"></exception>
        public static String MakeRelativePath(String fromPath, PathIs fromIs, String toPath, PathIs toIs)
        {
            if (String.IsNullOrEmpty(fromPath)) throw new ArgumentNullException("fromPath");
            if (String.IsNullOrEmpty(toPath)) throw new ArgumentNullException("toPath");

            //Slash am Ende anfügen, damit Uri damit klarkommt und weiß, was ein Folder ist, und was nicht
            if (!fromPath.EndsWith(Path.DirectorySeparatorChar.ToString()) &&
                !fromPath.EndsWith(Path.AltDirectorySeparatorChar.ToString()) &&
                fromIs == PathIs.Folder)
                fromPath += Path.DirectorySeparatorChar;
            if (!toPath.EndsWith(Path.DirectorySeparatorChar.ToString()) &&
                !toPath.EndsWith(Path.AltDirectorySeparatorChar.ToString()) &&
                toIs == PathIs.Folder)
                toPath += Path.DirectorySeparatorChar;

            Uri fromUri = new Uri(fromPath);
            Uri toUri = new Uri(toPath);

            if (fromUri.Scheme != toUri.Scheme) { return toPath; } // path can't be made relative.

            Uri relativeUri = fromUri.MakeRelativeUri(toUri);
            String relativePath = Uri.UnescapeDataString(relativeUri.ToString());

            if (toUri.Scheme.ToUpperInvariant() == "FILE")
            {
                relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
            }
            if (relativePath == string.Empty)
                relativePath = ".\\";
            //ein \ am Ende entfernen, dies macht Probleme, insbesondere in CommandLine wenn quoted
            //zudem scheint der .Net - Standard zu sein, kein \ am Ende zu haben vgl. Path.GetDirectoryname()
            return relativePath.TrimEnd(Path.DirectorySeparatorChar);
        }
开发者ID:kazyx,项目名称:SvgToXaml,代码行数:44,代码来源:FileUtils.cs

示例8: JoinPath

 /// <summary>
 /// 自动根据系统追加一级目录
 /// </summary>
 /// <returns></returns>
 public static String JoinPath(String path,String dir)
 {
     dir = dir.Replace("\\", "").Replace("/", "");
     try
     {
         if (path.EndsWith("\\") || path.EndsWith("/"))
         {
             if (SystemInfo.IsWindows)
                 return path += dir + "\\";
             else
                 return path += dir + "/";
         }
         else
         {
             if (SystemInfo.IsWindows)
                 return path += "\\" + dir + "\\";
             else
                 return path += "/" + dir + "/";
         }
     }
     catch
     {
         return path += "\\" + dir + "\\";
     }
 }
开发者ID:mfz888,项目名称:xcore,代码行数:29,代码来源:PathTool.cs

示例9: IsTagOpen

 bool IsTagOpen(String sb)
 {
     if (sb.StartsWith("</") && sb.EndsWith(">"))
         return false;
     else if (sb.StartsWith("<") && sb.EndsWith(">"))
         return true;
     else return false;
 }
开发者ID:nutinka,项目名称:HackBulgariaCourse,代码行数:8,代码来源:XmlMarkupBuilder.cs

示例10: StripQuotes

 private static String StripQuotes(String value)
 {
     if (value.StartsWith("\"") && value.EndsWith("\"")) {
         value = value.Substring(1, value.Length - 2);
     } else if (value.StartsWith("\'") && value.EndsWith("\'")) {
         value = value.Substring(1, value.Length - 2);
     }
     return value;
 }
开发者ID:deveel,项目名称:dshell,代码行数:9,代码来源:EchoCommand.cs

示例11: makeAll

		/// <summary> Creates skeletal source code (without correct data structure but no business
		/// logic) for all data types found in the normative database.  For versions > 2.2, Primitive data types
		/// are not generated, because they are coded manually (as of HAPI 0.3).  
		/// </summary>
		public static void makeAll(String baseDirectory, String version)
		{
			//make base directory
			if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
			{
				baseDirectory = baseDirectory + "/";
			}
			FileInfo targetDir =
				SourceGenerator.makeDirectory(baseDirectory + PackageManager.GetVersionPackagePath(version) + "Datatype");
			SourceGenerator.makeDirectory(baseDirectory + PackageManager.GetVersionPackagePath(version) + "Datatype");
			//get list of data types
			ArrayList types = new ArrayList();
			OleDbConnection conn = NormativeDatabase.Instance.Connection;
			OleDbCommand stmt = SupportClass.TransactionManager.manager.CreateStatement(conn);
			//get normal data types ... 
			OleDbCommand temp_OleDbCommand;
			temp_OleDbCommand = stmt;
			temp_OleDbCommand.CommandText =
				"select data_type_code from HL7DataTypes, HL7Versions where HL7Versions.version_id = HL7DataTypes.version_id and HL7Versions.hl7_version = '" +
				version + "'";
			OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();
			while (rs.Read())
			{
				types.Add(Convert.ToString(rs[1 - 1]));
			}
			rs.Close();
			//get CF, CK, CM, CN, CQ sub-types ... 

			OleDbCommand temp_OleDbCommand2;
			temp_OleDbCommand2 = stmt;
			temp_OleDbCommand2.CommandText = "select data_structure from HL7DataStructures, HL7Versions where (" +
			                                 "data_type_code  = 'CF' or " + "data_type_code  = 'CK' or " +
			                                 "data_type_code  = 'CM' or " + "data_type_code  = 'CN' or " +
			                                 "data_type_code  = 'CQ') and " +
			                                 "HL7Versions.version_id = HL7DataStructures.version_id and  HL7Versions.hl7_version = '" +
			                                 version + "'";
			rs = temp_OleDbCommand2.ExecuteReader();
			while (rs.Read())
			{
				types.Add(Convert.ToString(rs[1 - 1]));
			}

			stmt.Dispose();
			NormativeDatabase.Instance.returnConnection(conn);

			Console.Out.WriteLine("Generating " + types.Count + " datatypes for version " + version);
			if (types.Count == 0)
			{
				log.Warn("No version " + version + " data types found in database " + conn.Database);
			}

			for (int i = 0; i < types.Count; i++)
			{
				if (!((String) types[i]).Equals("*"))
					make(targetDir, (String) types[i], version);
			}
		}
开发者ID:RickIsWright,项目名称:nHapi,代码行数:61,代码来源:DataTypeGenerator.cs

示例12: _HasPm

 //##################################################
 //# testing
 //##################################################//
 public static bool _HasPm(String s)
 {
     s = s.ToLower();
     if ( s.EndsWith("pm") )
         return true;
     if ( s.EndsWith("p") )
         return true;
     return false;
 }
开发者ID:pabplanalp,项目名称:pvmail,代码行数:12,代码来源:JwTimeParser.cs

示例13: ConvertStringToMilliseconds

        /// <summary>
        ///
        /// </summary>
        /// <param name="myString">String </param>
        /// <returns>The value in milliseconds</returns>
        public static Int32 ConvertStringToMilliseconds(String myString)
        {
            // Guard Block
            // String null
            // String ""
            // String "        "
            if (String.IsNullOrWhiteSpace(myString))
            {
                throw new ArgumentException("Value was null, empty, or not a recognized time format.");
            }

            // Try Parse in the hopes that they gave us a number without ANY suffix
            int num;
            bool res = int.TryParse(myString, out num);

            if (res)
            {
                // Log statement saying that we're good
            }
                // Hours suffix scenario - h
            else if (myString.EndsWith("h"))
            {
                myString = myString.TrimEnd(new char[] {'h'});
                bool x = int.TryParse(myString, out num);
                if (x)
                {
                    num = num * 3600000;
                }
                
            }
                // Minute suffix scenario - m
            else if (myString.EndsWith("m"))
            {
                myString = myString.TrimEnd(new char[] { 'm' });
                bool x = int.TryParse(myString, out num);
                if (x)
                {
                    num = num * 60000;
                }
            }
              // Second suffix scenario - s
            else if (myString.EndsWith("s"))
            {
                myString = myString.TrimEnd(new char[] { 's' });
                bool x = int.TryParse(myString, out num);
                if (x)
                {
                    num = num * 1000;
                }
            }
            else
            {
                throw new ArgumentException("Value is not a recognized time format.");
            }
            return num;
        }
开发者ID:catenn,项目名称:StringUtilityConversion,代码行数:61,代码来源:StringUtility.cs

示例14: CreateMediaInfoFromFilePath

 private MediaInfo CreateMediaInfoFromFilePath(String filePath)
 {
     return new MediaInfo
     {
         ContentType = filePath.EndsWith(".png") ? "image/png" : filePath.EndsWith(".jpg") ? "image/jpeg" : "image/png",
         MediaId = Guid.Parse(Path.GetFileNameWithoutExtension(filePath)),
         UserId = Uri.UnescapeDataString(Path.GetFileName(Path.GetDirectoryName(filePath))),
         CreatedAt = File.GetCreationTimeUtc(filePath),
     };
 }
开发者ID:gogosub77,项目名称:Kanae,代码行数:10,代码来源:MediaInfoFileSystemRepository.cs

示例15: makeAll

		/// <summary> <p>Creates skeletal source code (without correct data structure but no business
		/// logic) for all segments found in the normative database.  </p>
		/// </summary>
		public static void makeAll(String baseDirectory, String version)
		{
			//make base directory
			if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
			{
				baseDirectory = baseDirectory + "/";
			}
			FileInfo targetDir =
				SourceGenerator.makeDirectory(baseDirectory + PackageManager.GetVersionPackagePath(version) + "Segment");

			//get list of data types
			OleDbConnection conn = NormativeDatabase.Instance.Connection;
			String sql =
				"SELECT seg_code, [section] from HL7Segments, HL7Versions where HL7Segments.version_id = HL7Versions.version_id AND hl7_version = '" +
				version + "'";
			OleDbCommand temp_OleDbCommand = new OleDbCommand();
			temp_OleDbCommand.Connection = conn;
			temp_OleDbCommand.CommandText = sql;
			OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();


			ArrayList segments = new ArrayList();
			while (rs.Read())
			{
				String segName = Convert.ToString(rs[1 - 1]);
				if (Char.IsLetter(segName[0]))
					segments.Add(altSegName(segName));
			}
			temp_OleDbCommand.Dispose();
			NormativeDatabase.Instance.returnConnection(conn);

			if (segments.Count == 0)
			{
				log.Warn("No version " + version + " segments found in database " + conn.Database);
			}

			for (int i = 0; i < segments.Count; i++)
			{
				try
				{
					String seg = (String) segments[i];
					String source = makeSegment(seg, version);
					using (StreamWriter w = new StreamWriter(targetDir.ToString() + @"\" + GetSpecialFilename(seg) + ".cs"))
					{
						w.Write(source);
						w.Write("}");
					}
				}
				catch (Exception e)
				{
					Console.Error.WriteLine("Error creating source code for all segments: " + e.Message);
					SupportClass.WriteStackTrace(e, Console.Error);
				}
			}
		}
开发者ID:RickIsWright,项目名称:nHapi,代码行数:58,代码来源:SegmentGenerator.cs


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