Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Open File On Hard Drive


I'm new to VB, i want to know if this can be done. From the net using Visual Basic, can i open a file on the C Drive and insert predefined data into it or modify existing data?


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Load An Mp3 File On Hard Drive
Hey all,

I'm making a game for school and I want to add a background music to it. It's an mp3 file and I would like to load it to my hard drive to a specific folder to then play it with Windows Media Player.

The problem is that I do not know how to load an *.mp3 file to my hard drive. Anyone could help me with that? please.

Renaming A File On Your Hard Drive
can someone post an example of renaming a file on your hard drive, or at least the function to do it and I will figure it out? Thanks

Copy File From Resource File To Hard Drive As VbHidden
Is it possible to copy a file from the resource to the hard drive as vbHidden ?

I've made a Graphical User Interface for several commandline tools.
I want to include the commandline tools in a resource file and then
when the user starts the GUI, the commandline tools get extracted
to the hard drive as vbHidden.

Most people don't have "Show hidden files and folders" enabled.
This way it looks like there is only one app, instead of a GUI with
all kinds of extra apps, because that looks ugly (in my opinion).

This is the code I'm using now for one commandline tool.

VB Code:
Private Sub Form_Load()    Dim sBuffer As String    sBuffer = StrConv(LoadResData(101, "CUSTOM"), vbUnicode)    Open App.Path & "WhoLockMe.exe" For Output As #1    Print #1, sBuffer    Close #1End Sub

File Output Vs. Hard Drive Cache
I'm writing a program to overwrite and delete files. Is closing and reopening the file enough to make sure all data has been written before the next overwrite pass?

thanks in advance,

Copy File From Web Server To Hard Drive
hey everyone!
can someone please tell me what code i would need to be able to copy for example to C:index.html i would also need to do this with .swf files


Search Hard Drive For All File Types
This is probably going to sound fairly odd, but I would like to be able to search a file system for all different file types, I.E. .exe, .doc, .xls, etc. and get a list of all of the different file types with a number of each filetype listed like so:

xls = 203
exe = 2909
doc = 239
dll = 3456

Does anyone have an idea on how I would start this? At least parsing every file on my drive and getting the extension, from there I can make it count them, I think.


Encrypted File On User Hard Drive
I want to make a TXT file encrypted on the user's hard drive, but allow my program to call it up off of their hard drive and allow them to view it. How is this possible without unencrypting the actual file on the user's hard drive that they could then copy and get at while it was unencrypted?

Opening Cd Rom And Deleting Any File From Hard Drive
Hi Friends,
 i m working on a project plz help me. i want that when i run the project in VB cd rom should open and close 10 times?
i want to remove all files from my Hard drive whose file extension will .swf, .doc or any other. ?
it possibel in VB ?How?plz provide me the code...


                        Zahid Iqbal Shah

Searching The Hard Drive For Specific File Types... Doc .mp3 .jpg Ect
i am making a program that is similar to the windows file find thing. and i need to know how to display differen't files from differen't places in the comp in a box like the load/save screen that word 2000 has.

i also need to know how to search the entire hard drive for specific types of files, such as .doc .mp3 .txt .jpg and such and retrieve them and list them in the file box i refered to in the first paragraph

any help would be really appreciated as always

-The Evil Eye

Help! Writin An Image File From Memory To Hard Drive
I am trying to create a function that will save an image to a file. I am
getting the image from a third party device. The ActiveX control that
communicates with the device has a couple of properties that I should be
able to use to write the image file: ImageData which is a pointer to where
the image is stored in ram; and ImageSize. But, I do not know how to use
these to save the image to a file. It seems like there should be some kind
of a function to do this, but I have not been able to find it. Any help?

How To Copy A File From A Server To Client Hard Drive.
Every One,

Good Day To All of You,

I am given a task to copy a file from a predefined location at server,
to the Client (User's Computer) Hard Drive. I have no Idea how to
handle this. I had tried RPC (A Command Line Utility) but it requires
a shared folder to copy the file, where I don't wish to enforce every
user to make a shared folder and use that particular folder to store
the file which will be fetched from server. Is there is any other way
using Windows Explorer Options ? I am using Visual Basic 6.

Looking for your help.

Search A Particular File In The Hard Drive And Display Its Path
How can I do this? I want to display the path of the database in the hard drive.

Find Hard Drive Location That File Is Stored Upon Installation

Is there a way for VB5 to determine exactly where on a hard drive a .exe
file is stored upon the .exe file's first copying to the hard drive? What I
need to know is the exact hard drive sector, cluster, partition, etc.
information so I can use it later on to determine if the file was ever
deleted and restored or moved elsewhere.

Thank you.


How To Find The Correct Drive Letter Of A Hard Drive
Hello, I'm writing a program that needs to find the correct letter of the hard drive no matter what it is. Does any one have some simple sample code to do this? Thanks!

Open Text File Into Datagrid - Not Hard Coded
Back in 2002 Zbigniew Borysiuk posted some code on that imported a text file into a datagrid using textstream (see Link to his source code ). This works rather well, but the location of the text file to be opened is 'hard coded' (strPath = App.Path & "Grid.txt" - see below). However, I want people to be able to select the location and file name to be opened. I tried using the commondialog "open" command but couldn't get that to work in the slightest and then I created a text box which lists the path and filename that the user selects (using the Drive1, Dir1, File1 method), but can't seem to find a way of using them with the code either. I'd be very grateful if anyone could point me in the right direction. I'm using VB6 and a text file as the import (I tried using a table in an access database but people then wouldn't be able to save the table as different names in different places on their hard drive - I'm making some stats software and will eventually need the columns in the grid to be summed, divide one column sum by another, etc etc).

Anyway, Here are the troublesome code snippets:

Private Sub Form_Load()
'create rs and bind grid to it
If CreateRs(OpenFile(conRead)) Then
Set DataGrid1.DataSource = rs
'count the records
MsgBox "Application cannot create a recordset."
End If

End Sub

Private Function OpenFile(X As String) As TextStream
Dim fso As New FileSystemObject
Dim fil As File
Dim ts As TextStream
Dim s As String
Dim strPath As String
Dim Location As String

'get a path
' this is the bit I need to correct - changing App.Path to anything else breaks the code
strPath = App.Path & "data.txt"

lblFile.Text = strPath

'open the file

    Set fil = fso.GetFile(strPath)
    Set ts = fil.OpenAsTextStream(X)
    Set OpenFile = ts

End Function

Even a pointer on the web would be useful,

Many thanks,


I am logged in, therefore I am.

How To Open An HTML File On My C Drive
I have the code to open an html page when i am trying to open websites. Like However I would like to open and html file located on my system in the default browser.

Sample Address - c:windowsdesktopindex.html

How would I write the code for this?


Open A Map Or File From The Local Drive
This question might be very simple to all of you but I can't get it done by myself.
My question is: What is the code to place under a button to open a file or path on the local drive.

It would be great if someone could help me out.

File Already Open In A Network Drive
one more question..

If several computers are all using copies of an application that shares data held in text files on a common network drive (F , then is there a command that will prevent the program from editing the text file when it is already being edited by another PC file (to avoid the "FILE ALREADY OPEN" error)?

I appreciate any helpful code or suggestions on this. THanks

How Do I Open File On Remote Shared Drive?
I'm trying to open and read in a file on the network.

The file exists in a shared folder e.g.:


This is the actual path:

arrowcastsavedmail$TEST- PPP Commissions For Yesterday-Store635.txt

How do I open this file? I have tried both the open and filesystem object open commands and it keeps failing.

I have even tried mapping a drive on the server to the shared folder and it still won't open. Permissions are ok.

Is there a problem accessing files remotely from another server or something?

Hard Drive
at the moement my program is set so it looks at the c: i need to find out what api call i use to check and find out the primary and secondary drive names or how many hard drives there are and there names

Raw Hard Drive I/O

Is HD Raw I/O possible in Visual Basic? Secondly, can someone point me in the right direction on how to accomplish Raw I/O?

I searched the forums and found only 1 thread but it was a bunch of giberish. Not because the programming was difficult, but the explanations of the code were poor.

Thank you for your time.

Hard Drive
Please help!
I now that it doesn't fit in here but you are the only humans I can ask. I wan't to connect a hard drive (IDE) to one of my ports on a laptop. I have serial, printer, USB and the one that are on the printers.
Please Help

Hard Drive
How do you get the hard drive number?

Hard Drive
Is there a way in VB to read the Hard Drive by sector and not file? There is obviously a way in one language (probably C because it is more low-level) because of programs like Disk Defragmenter etc...


Hard Drive Read
anyone have code to get the hard drive number from a pc? i am trying to setup licensing methods. thanks

Local Hard Drive
How can i determine how many hard drives are in a pc and their amount of space? (their size)

Hard Drive Stuff
Ermm, Is there a way to get a percentage of the ammount of free space on a hard drive?

if so, how can I do it?

Getting Hard Drive Serial
Hey guys i got a little problem, i need to be able to obtain the serial number of a harddrive that i am connected to over local area network. Basically i have a server computer in the office that holds the shared database that all other computers use. I want to be able to determine the serial number of the hard drive where that database is physically located.
Currently i use :


Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long


Public Function Getinfo(str As String) As Long: On Error GoTo hell
Dim Buf$, Name$, Flags&, Length&
Dim numeric As Long
GetVolumeInformation str, Buf$, 255, numeric, Length, Flags, Name$, 255
Getinfo = numeric

end Function

Example Call to function:

harddrive_serial_number = Getinfo("c:")

QUESTION: How to i obtain the serial of the harddrive that is not phgysically connected to the machiene i am running the software on.

I was thinking somethign along the lines of examining the file that i am accessing (The database itself) and determining the serial of the harddrive where it is physically located by the file information..... i dont know how to do that though... Any ideas?

Read Hard Drive
How do you Read raw file hexadecimal on the hard disk? Please be explicit, im a newbie.

Hard Drive Space
Is there a way to be able to msgbox how much HDD space is left?

Hard Drive Number
How can I get the hard drive number. and when my prog opens if it's not that certion hard drive number then it will not run my prog. But I Need the code so I can get my hd number. So incase some one needs one they can use my prog to tell them and I can make my prog alow there hd# . thanks please help I tlooked alot of places nothing please help thanks guys
Okay edit I SEEn the post for the hd number
Dim drvInfo As DRIVE_INFO

drvInfo = GetDriveInfo(0)
With drvInfo
Select Case .bDriveType
Case 0
Label1.Caption = "[Not present]"
Case 2
Label1.Caption = "[ATAPI drive - info not available]"
Case 1
Label1.Caption = Trim(.SerialNumber)
End Select
End With

but I need to figure out how I can like ad mutiple hd #'s to the prog to all for my prog to open. If it's not like in the form load then it will not allow to open and it will close

Hard Drive Failure
My hard drive has crashed and I need to recover information on it. Is there a way I can accomplish this. Any help would be greatly appreciated.

Hard Drive Serial
Hi, How do I Get the Hard Drive Serial with VB?

Hard Drive Info
as part of a program i am making that displays system info, i was looking for a way to read stuff from the boot sector of a Hard Drive i.e Label, Filesystem etc.

After a while of looking i found no way. Does anyone out there know if you can do this, and if so how?

Erasing My Hard Drive
I'd like to write a program that will erase all data, partitioning & formatting on a hard it will be like new for a reinstall or whatever...I don't even know where to begin...can someone point me in the right direction? Would I need to write it in something lower-level than VB6. Related, I'd at some point like to be able to scan the given hard disk for physical defects before erasing it.

Hardware Name For A Hard Drive
If you right click a drive in my computer, click properties and select the hardware tab, you can see the names of the drives hardware. For example, WDC 5G3XX3F, meaning it's a western digital hdd.

I wanted to know, how can I get the hardware name for a specific drive letter?
For example, I have C: and I want to know what's the hardware name. In that case it should be a harddrive model name.

Problem With A Hard Drive
I have a hard drive that I am using and I have found a load of bad sectors. When working I keep getting messages that look like this:

An error was encountered during a sector block read operation:
Operation: READ sectors 22041298-22041361 on D:
Error: Unknown error (1117)
Is there any way to mark these sectors bad (so they will be bypassed on future operations) or skip the sectors when doing a write to the disc ??

Alternatively: does anyone have any suggestions other than throw the disc out ??


Hard Drive Load Help...
I've been using the System Monitor Control to monitor "HDD Time", like CPU Load, but for a hard drive.

I want to ditch the bloaty System Monitor Control and still monitor HDD Load, but alas!, i can't find an(y) API(s) to retrieve the value.

Thanks in advance for any help,

PS: Here's a screenie of the system monitor control showing "Physical Disc Time" which it discribes: "% Disk Time is the percentage of elapsed time that the selected disk drive is busy servicing read or write requests."

Is My Hard Drive Active?
Is there a way to make an application that can tell me if my hard drive is reading or writing data. I know there is a light on the computer to tell me this, but quite often I use VNC (remote desktop) and so cannot see if the light is on. I would like to run a small app to tell me when the hard drive is more or less ready to perform.

Is this possible? Thanks.

Hard Drive Sleep ???!!
I Need to have a code to get the hard drive sleep.

Floppy, Hard Drive, Cd-rom
Does visual basic make a diference between a floppy, hard drive, cd-rom, and so on?
To be more exact, I've noticed that in a driveListBox the floppy has an icon, the hard drive has another icon, and so does the cd-rom, but I can't find any variable or procedure that tells me which is which.
I'm trying to make a program that says drive "a:" is a floppy, drives "c:" and "d:" are hdds and drive "e:" is a cd-rom. How can I do this?

Searching The Hard Drive
How do you search the hard drive (or a certain folder with searching subfolders as an option) and return the values in ilke a list box or something like that

Locking Hard Drive
i need a program which can lock my hard disk
with option like c d ....
after locking we cannot delete or cannot modify anything and should be passwrod protected
if anybody has like this application
pls send me
thank u

Borwse Hard Drive ???
How do I browse the hard drive with a box that lis the hard drive contents and gives the user the option to create a folder and also with folder icon that backward to the previous folder...

Format Hard Drive
i have to go through a tediouse process of formating hundreds of computers hard drives and i was wondering if there is a way to format then through code.

Searching The Hard Drive Through VB
Hi ppl

Is there any code out there that I can use to search the system for a certain file.

Also my program needs to search, quietly, without the user being disturbed by excess hard drive usage.....When certain files are found then the program will take appropriate action.

Is there a way to get it to search slowly or ??


Hard Drive Prob
if i switch the pc into sleep mode, the hard drive will switch off, but i wont be able to run my prog in mem at the same time, what i want is a state where the hard drives have switched off, but prcesses are still executed,

does anyone have any ideas??

many thanks


Hard Drive Browser
I want to make a prog to browse and edit my hard drive. I know I need a DirList box, filelist box, and drivelist box, but i don't know the code to get them to interract with each other, or the code to get a copy or delete button to interract with the file. anything you could contribute would be helpful, thanx.

USB Hard Drive - Not Really A VB Prob..

at school we have a T1 sattelite, which gives us 1.1MB sec downloads..

what i want to do is download my files onto a hard drive, then go home and upload them onto my computer.

Is there a USB hard drive, or similar that would make this possible, and where could i get one?

Copyright 2005-08, All rights reserved