将输入字符串转化为合法的文件名称
将输入字符串转化为合法的文件名称
using System;
using System.Text;
namespace ConvertFilenameToValid
{
//z 2012-3-5 13:17:35 PM IS2120@CSDN
class Program
{
static void PrintUsage ()
{
System.Console.WriteLine ("Usage : ");
System.Console.WriteLine (System.Reflection.Assembly.GetEntryAssembly ().GetName ().Name + " filename");
}
static void OutputValidFilename (StringBuilder fileName)
{
foreach (char c in System.IO.Path.GetInvalidFileNameChars ())
{
fileName = fileName.Replace (c, '_');
}
System.Console.WriteLine (fileName);
}
//z 2012-3-5 13:17:35 PM IS2120N
static void OutputValidFilename (string _fileName)
{
StringBuilder fileName = new StringBuilder (_fileName);
OutputValidFilename (fileName);
}
static void Main (string[] args)
{
if (args.Length != 1)
{
PrintUsage ();
return;
}
OutputValidFilename (args[0]);
return;
}
}
}
//z 2012-3-5 13:17:35 PM IS2120@CSDN
using System;
using System.Text;
namespace ConvertFilenameToValid
{
//z 2012-3-5 13:17:35 PM IS2120@CSDN
class Program
{
static void PrintUsage ()
{
System.Console.WriteLine ("Usage : ");
System.Console.WriteLine (System.Reflection.Assembly.GetEntryAssembly ().GetName ().Name + " filename");
}
static void OutputValidFilename (StringBuilder fileName)
{
foreach (char c in System.IO.Path.GetInvalidFileNameChars ())
{
fileName = fileName.Replace (c, '_');
}
System.Console.WriteLine (fileName);
}
//z 2012-3-5 13:17:35 PM IS2120N
static void OutputValidFilename (string _fileName)
{
StringBuilder fileName = new StringBuilder (_fileName);
OutputValidFilename (fileName);
}
static void Main (string[] args)
{
if (args.Length != 1)
{
PrintUsage ();
return;
}
OutputValidFilename (args[0]);
return;
}
}
}
//z 2012-3-5 13:17:35 PM IS2120@CSDN
@IS2120#CNBLOGS.T2169364049[T1,L65,R1,V259]:备忘
$ € ₤ ₭ ₪ ₩ ₮ ₦ ₱ ฿ ₡ ₫ ﷼ ¥ ﷼ ₫ ₡ ฿ ₱ ₦ ₮ ₩ ₪ ₭ ₤ € $