StringUtils.FixDirectorySeparators C# (CSharp) Method

FixDirectorySeparators() public static method

Replaces all directory separators with the correct one for the current platform (either / or \).
public static FixDirectorySeparators ( string path ) : string
path string
return string
    public static string FixDirectorySeparators(string path)
    {
        StringBuilder sb = new StringBuilder(path);
        sb.Replace('/', Path.DirectorySeparatorChar);
        sb.Replace('\\', Path.DirectorySeparatorChar);
        return sb.ToString();
    }

Usage Example

Exemplo n.º 1
0
        protected override void GenerateTexture()
        {
            string savePath = EditorUtility.SaveFilePanel("Choose where to save the texture.",
                                                          Application.dataPath, "MyTex.png", "png");

            if (savePath.Length == 0)
            {
                return;
            }

            //Write out the texture as a PNG.
            Texture2D noiseTex = GetPreview(false);

            try
            {
                File.WriteAllBytes(savePath, noiseTex.EncodeToPNG());
            }
            catch (Exception e)
            {
                Debug.LogError("Unable to save texture to file: " + e.Message);
            }

            //Finally, open explorer to show the user the texture.
            EditorUtility.RevealInFinder(StringUtils.FixDirectorySeparators(savePath));
        }
All Usage Examples Of StringUtils::FixDirectorySeparators