Results for "Category: Files/ File Controls/ Input/ Output"
Allows you to backup a source file and have the destination file name be the current date. Great for database backups!
This very simple routine avoid checking if a correct path already exist before using it and, if not, create it exactly as you want. Imagine you wont to write a log file in a path defined as: C:\Myapplic\Services\logs\LOG.TXT you must check before if the directory Myapplic exist and then check all other subdirectory (Service,logs) before opening the file For Output. Probably you will use a lot of Error Resume Next, Mkdir(...), Error GoTo 0, dir(....) and so. Instead you can use this routine as described below: Myfile="C:\Myapplic\Services\logs\LOG.TXT" Call CheckDir(Myfile) nf=FreeFile() Open Myfile For Output As #nf . . . Close #nf and including the following .bas module: Public Sub CheckDir(file) Ix = 4 'Initial index KSlash = InStr(1, file, "\", 1) 'Search for first "\" For Cnt = 1 To Len(file) 'Run until discover 'other directories KSlash = InStr((KSlash + 1), file, "\", 1) If KSlash = 0 Then Exit For 'Last slash dir1 = Left(file, (KSlash - 1)) cdir1 = Mid(dir1, Ix) Ix = Ix + Len(cdir1) + 1 hh = Dir(dir1, vbDirectory) 'If Directory doesn't exist, create it If StrComp(hh, cdir1, 1) 0 Then MkDir (dir1) End If Next Cnt End Sub
For those of you who want to add a touch of professionalism to your program, now you can create a file type in the Windows Registry database which will associate all files ending with your program's file extension ( yourfile.xxx) to your program. You also specify an icon for your file type and a description. This example also shows you how to use Command$ to open these files in your program when once the file is clicked or opened, and a quick tip on creating files in the Windows Recent file folder (Start > Documents).
Read large text files faster. Reads lines in text files about 30% faster then the TextStream class. Skips much faster.
Uses the FindFile, FindNextFile, and SearchPath API functions to quickly find a file on your hard drive. Runs faster than methods which use Dir$.
These two functions are designed to read and write a file as fast as possible in VB. It is faster for some cases than WinApi Read/WriteFile functions because you don't have to convert binary to string in a loop. Thats why, it is very fast and useful for any purpose. I have created it for my Encryption programme and with Windows Crypto functions and this two functions, my encrytion programme works faster than most of the Encrytion software you can download on the net. Hope it will be useful for you. Thanks. Ozan Yasin Dogan www.uni-group.org (will be online in 01/06/02)
Embed binary files within your programs to be written out to the file system once the program runs. This demonstration creates a Word document.
The program can remove extentions from multipile files, or add them to the files. Prefect if you need to renmae *.--- files or to add --- extention. The code is simple and readable, easy to modify for your own use...
There are many methods you can use to return certain parts of a fully qualified path to a file. Here is the SHORTEST and FASTEST way to 1) return just the path, 2) return just the filename, and 3) change the extension of a filename. The code is so short that it is probably faster to keep it inline than to create additional functions. (I've done so here to better illustrate the parameters.
I haven't seen this on PSC using the filesystem object or a collection. very neat and fast since you don't need to go through it twice to redim an array. the only slow down with this code is the print statement.
Search for a directories, sub-directories and files and sub-files without having objects on your form! You can even search in more directories! or use file-filters (*.bat;*.com;*.exe;ect...) and file-attributes (read only, hidden, ect...) while you search! This all in just one simply command! This version is much easer to use than the preview demo version 1.0. The results in this version also doesn't import duplicated results and some bugs are fixed. The results gives now also the size, date & time, and attributes. In the next version I will add some more commands, like a compleet directory/file browser. It sounds unbelievable but it's true. It's very easy and fast to use and it's over 100% user friendly! No heavy codes anymore just use this for all your codes! Download the file and see it yourself, I know you'll love this code!!!... I will release more codes when you vote for me, happy coding...
Normal users use the Shell command, but that command can't execute all kind of files, but this can
commonly needed file macros you hate to code over and over. Functions: GetFolderFiles, GetSubfolders, FileExists, FolderExists, SafeFileName, Read/Write/AppendFile, GetFreeFilename, FileNameFromPath,ChangeExtension, etc.. anyway this will help you clean up your code alot and make it more readable Dont forget to check my sight for more stuff: http://geocities.com/dzzie
Calculate Pi. This will only let you go to 32763 decimal places. ************************************************* If anyone nows any API for larger math please leave comment about it. *************************************************
Retrieve the version of a file (EXE/DLL etc). This code should be paste into a module and just called via CheckFileVersion('Path to the Exe or DLL').
This DOES use the kill function, but when you use this it actually opens the file you want to destroy, cleans it out, then deletes it so you don't get any error because of sensitive data!
Opens a text file much fast than a "Do While Not EOF(filenumber)" loop. Makes file load times almost non-existant.
These two functions will return the location of the Windows directory (WinDir) and the location of the System directory (SysDir).
Sets a file's attributes. With this you can create archive, hidden, normal, read-only, and system files.
This code demonstrate a simple procedure for reading and writing to and from a text file. Level: Beginners