|
-
Sep 23rd, 2002, 12:55 AM
#1
Thread Starter
Hyperactive Member
Get file size
How do I get the size of a file?
-
Sep 23rd, 2002, 01:00 AM
#2
VB Code:
Imports System
Imports System.IO
Public Module modmain
Sub Main()
'KPD-Team 2001
'URL: [url]http://www.allapi.net/dotnet/[/url]
Dim MyFile as new FileInfo ("c:\autoexec.bat")
Console.WriteLine("The length of autoexec.bat is " _
+ MyFile.Length.ToString + " bytes.")
End Sub
End Module
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Sep 23rd, 2002, 01:23 AM
#3
Thread Starter
Hyperactive Member
Hey thanks for the quick reply. If you could answer a few more noob questions, you will help me on my way.
I tried to use the same technique to get a dirs parent dir....but no luck
VB Code:
Private Sub SearchDir(ByVal TargetDir As String)
Dim Files() As String
Dim File As String
Dim Dirs() As String
Dim Dir As String
Dim FileInfo As IO.FileInfo
Dim DirInfo As IO.DirectoryInfo
Dirs = IO.Directory.GetDirectories(TargetDir)
lstDirs.Items.Clear()
lstDirs.Items.Add("UP")
For Each Dir In Dirs
lstDirs.Items.Add(Dir)
Next
Files = IO.Directory.GetFiles(TargetDir, "*.*")
lsvFiles.Items.Clear()
For Each File In Files
'add item to list view box
lsvFiles.Items.Add(File)
FileInfo = New IO.FileInfo(File)
lsvFiles.Items(lsvFiles.Items.Count - 1).SubItems.Add(FileInfo.Length)
Next
'store parent directory
DirInfo = New IO.DirectoryInfo(TargetDir)
UpDir = DirInfo.Parent.ToString 'causes error
End Sub
Also, how do you change the mouse cursor? In VB6...twas
VB Code:
me.mousepointer = vbhourglass
me.mousepointer = vbDefault
??????
?????
????
-
Sep 23rd, 2002, 01:28 AM
#4
-
Sep 23rd, 2002, 01:48 AM
#5
Thread Starter
Hyperactive Member
Thanks Mr.Polite. You have been a great help.
The cursor code worked great. Here is what I ended up using for the DirInfo
VB Code:
dim DirInfo as IO.DirectoryInfo
'later in sub (in a loop)
DirInfo = New IO.DirectoryInfo(TargetDir)
UpDir = DirInfo.Parent.FullName
The problem was that I was passing the root of the drive as the TargetDir and that was causing an error. I just needed some error handling.
More questions......
How do you do the Right, Left, and Mid string functions in VB.net?
-
Sep 23rd, 2002, 02:17 AM
#6
Thread Starter
Hyperactive Member
Got it from another post
Mystring.Substring()
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|