Created
December 29, 2014 16:46
-
-
Save 0V/d7a4388417c38e733ac4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Util | |
{ | |
public class FileUtility | |
{ | |
/// <summary> | |
/// ファイル名として使用可能な形にする。 | |
/// </summary> | |
/// <param name="name">元のファイル名</param> | |
public static string ValidFileName(string name) | |
{ | |
return ValidFileName(name, '_'); | |
} | |
/// <summary> | |
/// ファイル名として使用可能な形にする。 | |
/// </summary> | |
/// <param name="name">元のファイル名</param> | |
/// <param name="replaceChar">使用不可文字をこの文字に置き換えます</param> | |
/// <returns></returns> | |
public static string ValidFileName(string name, char replaceChar) | |
{ | |
var invalidChar = System.IO.Path.GetInvalidFileNameChars(); | |
foreach (char c in invalidChar) | |
name = name.Replace(c, replaceChar); | |
return name; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment