473,396 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

GetLongPathName API

I am having some strange problems with using the GetLongPathName API in a
..Net app that I am writing. Simply put, the app runs a process (invoked from
a dialog) that writes out temporary files to a scratch workspace. For
reasons that would take to long to explain, I am given a path to the scratch
workspaces in Short format. I am using GetLongPathName to, well get the
long path name.

So when the process runs, it writes out status messages to a textbox on the
dialog and scratch files to the temp workspace. Everything works as it
should on the first run of the process. However, on subsequent runs the
GetLongPathName is failing. It either returns nothing or strangely enough,
it returns the text that was written to the dialog textbox. Closing the
dialog and reopening does not help and I have to completely exit the app in
order to "reset" the GetLongPathName function.

Something else I have noticed is that I call the same function from another
pat of my app and its works great... never fails. This call is not being
made from a dialog so I suspect that has something to do with this.

Does anyone out there have any explanation as to what might be wrong here?
Here is the code I am using to wrap the API

Module MiscTools
Private Const bufferSize As Integer = 256

Public Class LongPathWrap
Declare Auto Function GetLongPathName Lib "kernel32.dll" (ByVal
shortPath As String, ByVal longPathBuffer As System.Text.StringBuilder, ByVal
longPathBufferSize As Integer) As Integer
End Class

Public Function GetLongPathName(ByVal shortPathName As String) As String
Dim buffer As New System.Text.StringBuilder(255)
Dim GLP As New LongPathWrap

Try
If shortPathName Is Nothing Then Return Nothing
Dim int As Integer
int = GLP.GetLongPathName(shortPathName, buffer, 255)
Return buffer.ToString
Catch ex As Exception
Return Nothing
Finally
buffer = Nothing
GLP = Nothing
End Try
End Function

End Module

Mar 31 '06 #1
1 2986
Hi,
Welcome to MSDN Newsgroup!

I can't repro this problem on my side. In the current scenario, I want to
confirm whether you can send me a complete sample to repro this question.
It will be better that the sample is written in C/C++. This will help us to
repro this issue and debug it on our side.

Thanks for your understanding!

Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
Thread-Topic: GetLongPathName API
thread-index: AcZU6ZL2qqqEK9xMSomuvmh/+g5M8g==
X-WBNR-Posting-Host: 140.90.54.57
From: =?Utf-8?B?c2F0ZWxpdGU=?= <sa******@newsgroups.nospam>
Subject: GetLongPathName API
Date: Fri, 31 Mar 2006 09:35:59 -0800
Lines: 52
Message-ID: <72**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
Newsgroups: microsoft.public.dotnet.general
Path: TK2MSFTNGXA01.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:192230
NNTP-Posting-Host: TK2MSFTNGXA01.phx.gbl 10.40.2.250
X-Tomcat-NG: microsoft.public.dotnet.general

I am having some strange problems with using the GetLongPathName API in a
.Net app that I am writing. Simply put, the app runs a process (invoked froma dialog) that writes out temporary files to a scratch workspace. For
reasons that would take to long to explain, I am given a path to the scratchworkspaces in Short format. I am using GetLongPathName to, well get the
long path name.

So when the process runs, it writes out status messages to a textbox on thedialog and scratch files to the temp workspace. Everything works as it
should on the first run of the process. However, on subsequent runs the
GetLongPathName is failing. It either returns nothing or strangely enough,it returns the text that was written to the dialog textbox. Closing the
dialog and reopening does not help and I have to completely exit the app inorder to "reset" the GetLongPathName function.

Something else I have noticed is that I call the same function from anotherpat of my app and its works great... never fails. This call is not being
made from a dialog so I suspect that has something to do with this.

Does anyone out there have any explanation as to what might be wrong here?
Here is the code I am using to wrap the API

Module MiscTools
Private Const bufferSize As Integer = 256

Public Class LongPathWrap
Declare Auto Function GetLongPathName Lib "kernel32.dll" (ByVal
shortPath As String, ByVal longPathBuffer As System.Text.StringBuilder, ByVallongPathBufferSize As Integer) As Integer
End Class

Public Function GetLongPathName(ByVal shortPathName As String) As String Dim buffer As New System.Text.StringBuilder(255)
Dim GLP As New LongPathWrap

Try
If shortPathName Is Nothing Then Return Nothing
Dim int As Integer
int = GLP.GetLongPathName(shortPathName, buffer, 255)
Return buffer.ToString
Catch ex As Exception
Return Nothing
Finally
buffer = Nothing
GLP = Nothing
End Try
End Function

End Module


Apr 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ken Dyck | last post by:
Is there a way with Python 2.2 to portably test the equivalence of two filenames? The os.path.samefile function seems to do what I want, but it is only available on Unix and Mac. I need...
6
by: Charles Conlow | last post by:
I'm certain there's a simple way to do this, but I just can't find the pointers... How to get the huge 'drive:\long\path\to get\there\filename.ext' to something like 'D:\Docu...\filename.ext' ...
1
by: Boris | last post by:
I have C++ .NET mixed (managed/unmanaged) application. I build it under W2K and it works fine. However when I tried to run it under NT 4.0 I've got the following error message: The procedure...
2
by: Matt Theule | last post by:
I need to be able to allow users to drag files to a list box on a web page. To this end, I created a Windows Control and hosted it in a WebForm. When the file is dropped onto the listbox, the...
4
by: Henry | last post by:
This function refuses to return the long path name when called on Windows 2000 Professional. It does not return an error value or raise an exception, it just does nothing. ...
4
by: yxq | last post by:
Hello, How to convert "c:\PROGRA~1" to "c:\program files" Thank you
1
by: Jim Tittsler | last post by:
I wrap my cross platform application up with py2exe on Windows, and have the installer associate a particular file type with it. When a user double clicks on a document to launch my application,...
0
by: mjheitland | last post by:
When I pass my directories recursively on a directory structure with paths 260 chars I get the following exception (see line marked with ***), although I am using only ShortPathNames through...
16
by: Stef Mientki | last post by:
hello, How can I find the correct case of a filename ? Background in my program I use case sensitive filenames, just like Python requires. Now I've integrated pdb into the program, but pdb...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.