lvnv
asked on
GetShortPathName
I would like to make "f.FileName" and "f.SelectedPath" below the short paths, but I'm not sure what I need to declare...I keep getting errors beyond the syntax of my GetShortPathName(xx,xxx,xx )
so I figured I'd just let someone get the points...
Here's the current code that I want to change to shortpath:
private void buttonBrowseFiles_Click(ob ject sender, EventArgs e)
{
using (OpenFileDialog f = new OpenFileDialog())
{
f.FileName = this.textBoxBackupSelectio n.Text;
f.Multiselect = false;
if (f.ShowDialog() == DialogResult.OK)
{
this.textBoxBackupSelectio n.Text = f.FileName;
}
}
}
private void buttonBrowseFolders_Click( object sender, EventArgs e)
{
using (FolderBrowserDialog f = new FolderBrowserDialog())
{
f.ShowNewFolderButton = false;
f.RootFolder = Environment.SpecialFolder. MyComputer ;
f.SelectedPath = this.textBoxBackupSelectio n.Text;
if (f.ShowDialog() == DialogResult.OK)
{
this.textBoxBackupSelectio n.Text = f.SelectedPath;
}
}
}
so I figured I'd just let someone get the points...
Here's the current code that I want to change to shortpath:
private void buttonBrowseFiles_Click(ob
{
using (OpenFileDialog f = new OpenFileDialog())
{
f.FileName = this.textBoxBackupSelectio
f.Multiselect = false;
if (f.ShowDialog() == DialogResult.OK)
{
this.textBoxBackupSelectio
}
}
}
private void buttonBrowseFolders_Click(
{
using (FolderBrowserDialog f = new FolderBrowserDialog())
{
f.ShowNewFolderButton = false;
f.RootFolder = Environment.SpecialFolder.
f.SelectedPath = this.textBoxBackupSelectio
if (f.ShowDialog() == DialogResult.OK)
{
this.textBoxBackupSelectio
}
}
}
What do you mean by short path?
ASKER
GetShortPathName Function ... it's a M$ thing...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
graye - REALLY COOL SITE ... I will definitely use that more in the future!
it should be called more than anyone ever needed to know about p/invokes...
but where do I put this?
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern uint GetShortPathName([MarshalA s(Unmanage dType.LPTS tr)] string lpszLongPath,
[MarshalAs(UnmanagedType.L PTStr)] StringBuilder lpszShortPath,
int cchBuffer);
it should be called more than anyone ever needed to know about p/invokes...
but where do I put this?
[DllImport("kernel32.dll",
static extern uint GetShortPathName([MarshalA
[MarshalAs(UnmanagedType.L
int cchBuffer);
just put it inside a class somewhere, and then call it like any other part of the language/framework, such as
StringBuilder sb = new Stringbuilder(12);
GetShortPathName("c:\\some longfilena me.text", sb);
StringBuilder sb = new Stringbuilder(12);
GetShortPathName("c:\\some
ASKER
I get this error:
"the type or namespace name 'DllImport' could not be found (are you missing a using directive or an assembly reference?)
<aside: the grammar seems weird in the error, but that's what it says>
I sure thought this would be easier than it has turned out...
GRRR....
"the type or namespace name 'DllImport' could not be found (are you missing a using directive or an assembly reference?)
<aside: the grammar seems weird in the error, but that's what it says>
I sure thought this would be easier than it has turned out...
GRRR....
ASKER
using System.Runtime.InteropServ ices;
needs to be at the top...
I sure with that there was a definitive guide to this. My style of learning just doesn't seem to agree with the M$ documentation...
needs to be at the top...
I sure with that there was a definitive guide to this. My style of learning just doesn't seem to agree with the M$ documentation...
ASKER
that's really a good site!