473,383 Members | 1,832 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,383 software developers and data experts.

filename in 8.3 format

The filesystemobject file object had a shortname property which was the
filename in 8.3 format. I have not been able to locate in system.io an
equivalent property. Is there an equivalent in system.io or do I need to
stick with the filesystemobject in order to have access to this property?
Nov 21 '05 #1
6 1765
On Thu, 12 Aug 2004 20:21:02 -0700, Engineerik wrote:
The filesystemobject file object had a shortname property which was the
filename in 8.3 format. I have not been able to locate in system.io an
equivalent property. Is there an equivalent in system.io or do I need to
stick with the filesystemobject in order to have access to this property?


I don't know of anyway - except via P/Invoke to the GetShortPathName api...
Here is a simplfied example:

Option Strict On
Option Explicit On

Imports System

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(0, 0)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(288, 20)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.TextBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Const MAX_PATH As Integer = 260

Private Declare Auto Function GetShortPathName Lib "kernel32" ( _
ByVal lpszLongPath As String, _
ByVal lpszShortPath As System.Text.StringBuilder, _
ByVal cchBuffer As Integer) As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim path As String =
Environment.GetFolderPath(Environment.SpecialFolde r.Personal)

Dim buffer As New System.Text.StringBuilder(MAX_PATH)
GetShortPathName(path, buffer, buffer.Capacity)
TextBox1.Text = buffer.ToString()
End Sub
End Class
--
Tom Shelton [MVP]
Nov 21 '05 #2
Erik,

I only know the API

http://msdn.microsoft.com/library/de...rtpathname.asp

However I assume that that is the same for what you are not looking for.

Cor

"Engineerik" <En********@discussions.microsoft.com> schreef in bericht
news:DA**********************************@microsof t.com...
The filesystemobject file object had a shortname property which was the
filename in 8.3 format. I have not been able to locate in system.io an
equivalent property. Is there an equivalent in system.io or do I need to
stick with the filesystemobject in order to have access to this property?

Nov 21 '05 #3
Thanks for the reply but it looks like it may be simpler and just as clean to
add a reference to scrrun.dll and use the filesystemobject if I want 8.3
filenames.

Regards,
Erik

"Cor Ligthert" wrote:
Erik,

I only know the API

http://msdn.microsoft.com/library/de...rtpathname.asp

However I assume that that is the same for what you are not looking for.

Cor

"Engineerik" <En********@discussions.microsoft.com> schreef in bericht
news:DA**********************************@microsof t.com...
The filesystemobject file object had a shortname property which was the
filename in 8.3 format. I have not been able to locate in system.io an
equivalent property. Is there an equivalent in system.io or do I need to
stick with the filesystemobject in order to have access to this property?


Nov 21 '05 #4
In article <51**********************************@microsoft.co m>, Engineerik wrote:
Thanks for the reply but it looks like it may be simpler and just as clean to
add a reference to scrrun.dll and use the filesystemobject if I want 8.3
filenames.

Regards,
Erik


Huh? I showed an example of using this api. It is a very simple
matter. Believe me, referencing scrrun.dll is a bad idea if you can get
around it.

--
Tom Shelton [MVP]
Nov 21 '05 #5
On Fri, 13 Aug 2004 18:23:02 -0700, Engineerik wrote:
"Tom Shelton" wrote:

[snip] Believe me, referencing scrrun.dll is a bad idea if you can get
around it.

--
Tom Shelton [MVP]


Didn't mean to "dis" your reply. I was not familiar with the
GetShortPathName api so perhaps it was my familiarity with the
filesystemobject that made me call it simpler. You are correct
GetShorPathName is very simple.

I do wonder however, what makes referencing scrrun.dll such a bad idea?

Wouldn't referencing the properties of a filesystemobject.file object be
quicker processing timewise than calling a function against a system.io.file
instance?

Regards
Erik


Erik,

Referencing scrrun.dll is a bad idea for several reasons (in no particular
order)...

1. Performance. To use objects from scrrun.dll, you are crossing over into
the land of COM interop - which is very expensive, even compared to
P/Invoke (which is also expensive, but as bad as COM interop)

2. What do you do on a system that has disabled wsh?

3. There have been dll hell issues associated with wsh and scrrun.dll in
the past.

Overall - using System.IO.File is going to be much faster then using
FileSystemObjects from scrrun.dll. Basically, except for COM interop - it
is the same reasons not to use them in VB6. The code may look a little
cleaner - but it is probably half as fast as using the VB6 native IO.

--
Tom Shelton [MVP]
Nov 21 '05 #6
"Tom Shelton" wrote:
2. What do you do on a system that has disabled wsh?


LaserFiche is a document imaging system that has an import list feature. I
am writing an automated import list generator. Although LaserFiche itself
does not have any problem with long paths and filenames, the import list
feature still requires the 8.3 pathnames and filenames.
I expect LaserFiche will upgrade the import list feature ... eventually:-)
I am converting my vb6 code which used the filesystemobject to .NET and I
don't want to take my code down a deadend development path.
I'll definately use the api call instead of the scrrun.dll.

Regards,
Erik

Nov 21 '05 #7

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

Similar topics

1
by: rudderstick | last post by:
Hi there all, I have an interesting problem.... I work for a company that develops software for the building industry and would like to distribute one of our software products via the web. ...
8
by: bobrics | last post by:
Hi, I would like to save data from multiple repetitive simulations into a set of files. Each time a simulation restarts, I would like it to automatically generate a file with a name containing...
3
by: dick | last post by:
Hello, I want to encrypt a file with its filename. I can encrypt the file itself using the frame libraries. How can I now best hide the filename and extension? Within the file, ... ? I...
3
by: Crouchie1998 | last post by:
On the following page is for Symantec Antivirus updates: http://www.sarc.com/avcenter/download/pages/US-SAVCE.html Todays virus definition filename & path is: ...
4
by: Dave | last post by:
I am writing a C# app in which I need to enumerate the processes running on the PC. I have succesfully done this as follows (assuming the app is running on NT4, XP, 2000 or 2003): ...
4
by: B Squared | last post by:
I'm trying to pass a filename (which is a jpeg image) to a php function / file so that it will display. I know that its simple to get PHP to display an image hardcoding in the filename. For...
7
by: pedagani | last post by:
Dear comp.lang.c++, I'm trying to read a file with very long filename using ifstream. Although, the file exists the file open for read fails. Is there a restriction on the size? I'm using winXP...
12
by: vj | last post by:
I am using Borland C++. I run a program which generates output data files, say 'Voltage.dat', 'Current.dat'. I have a variable in my code (say N), and for various values of N (for each value of...
2
by: mcolorblind | last post by:
I would to ask help from you guys regarding my problem with VB6.0 + PDFCreator. i've been doing VB6.0 for quite some time now but this current project of mine will generate reports in a PDF format...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.