Beispiel #1
0
 /// <summary>
 ///     Saves data to file.
 /// </summary>
 /// <param name="fileFullName"></param>
 /// <param name="fileData"></param>
 public static void SaveCsvFile(string fileFullName, CaseInsensitiveDictionary <List <string?> > fileData)
 {
     using (var writer = new StreamWriter(File.Create(fileFullName), new UTF8Encoding(true)))
     {
         foreach (var fileLine in fileData.OrderBy(kvp => kvp.Key))
         {
             writer.WriteLine(FormatForCsv(",", fileLine.Value));
         }
     }
 }
        /// <summary>
        ///     result != null
        /// </summary>
        /// <param name="nameValueCollection"></param>
        /// <returns></returns>
        public static string GetNameValueCollectionString(CaseInsensitiveDictionary <string> nameValueCollection)
        {
            if (nameValueCollection is null || nameValueCollection.Count == 0)
            {
                return("");
            }

            var items = new List <string>();

            foreach (var kvp in nameValueCollection.OrderBy(i => i.Key))
            {
                items.Add(UrlEncode(kvp.Key) + @"=" + UrlEncode(kvp.Value));
            }

            return(String.Join("&", items));
        }