/********************************************************************************************* * Copyright 2004 - Volian Enterprises, Inc. All rights reserved. * Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE * ------------------------------------------------------------------------------ * $Workfile: ShrtNm.cs $ $Revision: 1 $ * $Author: Kathy $ $Date: 7/27/04 8:34a $ * * $History: ShrtNm.cs $ * * ***************** Version 1 ***************** * User: Kathy Date: 7/27/04 Time: 8:34a * Created in $/LibSource/Utils *********************************************************************************************/ using System; using System.Text; using System.Runtime.InteropServices; using System.ComponentModel; namespace Utils { /// /// Summary description for ShrtNm. /// public class ShortName { [DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)] [return:MarshalAs(UnmanagedType.U4)] public static extern int GetShortPathName( [MarshalAs(UnmanagedType.LPTStr)] string lpszLongPath, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpszShortPath, [MarshalAs(UnmanagedType.U4)] int cchBuffer); private string _LongFileName; private StringBuilder _ShortFileName; public ShortName(string longname) { _LongFileName = longname; _ShortFileName = new StringBuilder(256); int len = GetShortPathName(_LongFileName,_ShortFileName,256); if (len==256) _ShortFileName=null; if (len==0) _ShortFileName.Append(longname); } [Description("FileName")]public string ShortFileName { get{return _ShortFileName.ToString();} } } }