using System.IO; using System.Text; namespace CloudMosaic.Frontend { public static class Utilities { public static void CopyStream(Stream input, Stream output) { byte[] buffer = new byte[8 * 1024]; int len; while ((len = input.Read(buffer, 0, buffer.Length)) > 0) { output.Write(buffer, 0, len); } } public static string MakeSafeName(string displayName, int maxSize) { var builder = new StringBuilder(); foreach (char c in displayName) { if (char.IsLetterOrDigit(c)) { builder.Append(c); } else { builder.Append('-'); } } var name = builder.ToString(); if (maxSize < name.Length) { name = name.Substring(0, maxSize); } return name; } } }