Files
UnrealEngineUWP/Engine/Source/Programs/DotNETCommon/DotNETUtilities/FileSystem.cs
Ben Marsh 20bf0eb6a1 Updating copyright notices to 2017 (copying from //Tasks/UE4/Dev-Copyright-2017).
#rb none
#lockdown Nick.Penwarden

[CL 3226823 by Ben Marsh in Main branch]
2016-12-08 08:52:44 -05:00

33 lines
918 B
C#

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace Tools.DotNETCommon.FileSystem
{
public static class FileSystem
{
[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
private static extern int GetShortPathName(string pathName, StringBuilder shortName, int cbShortName);
public static string GetShortPathName(string Path)
{
int BufferSize = GetShortPathName(Path, null, 0);
if (BufferSize == 0)
{
throw new Exception(string.Format("Unable to convert path {0} to 8.3 format", Path));
}
var Builder = new StringBuilder(BufferSize);
int ConversionResult = GetShortPathName(Path, Builder, BufferSize);
if (ConversionResult == 0)
{
throw new Exception(string.Format("Unable to convert path {0} to 8.3 format", Path));
}
return Builder.ToString();
}
}
}