I want to read a file name so that I can open and edit it.In terbo C, i was using findfirst and findnext.But with DEV C++ these function are not helping me.Is there any other function to get filename in DEV c++(C langauge function).
help to read file name
Started by chetan21, Jun 24 2009 05:34 AM
12 replies to this topic
#1
Posted 24 June 2009 - 05:34 AM
|
|
|
#2
Guest_Jordan_*
Posted 24 June 2009 - 05:40 AM
Guest_Jordan_*
Moved to the correct forum. Are you looking to read the filenames in a particular directory?
#3
Posted 24 June 2009 - 05:48 AM
yes
files are going to be in perticular fixed location
files are going to be in perticular fixed location
#4
Posted 24 June 2009 - 06:21 AM
#5
Posted 24 June 2009 - 06:44 AM
Suppose there are 10 ".txt" files in folder c:\trial.
I need to rename these files, new name is inside that file.
Now to open these files using file function fopen, I need program to read filename first so that I can look into file further for new name.
In terbo C ,function findfirst was giving me file name in structure variable ffblk.name.see below command
"done = _dos_findfirst("C:/trial/*.*",_A_NORMAL,&ffblk);"
Now I suppose to use dev C++, and for same function it is giving error.
Is there any other way to read file name.
I WANT TO AVOID MANUAL ENTRY FOR OLD AND NEW FILE NAME
I need to rename these files, new name is inside that file.
Now to open these files using file function fopen, I need program to read filename first so that I can look into file further for new name.
In terbo C ,function findfirst was giving me file name in structure variable ffblk.name.see below command
"done = _dos_findfirst("C:/trial/*.*",_A_NORMAL,&ffblk);"
Now I suppose to use dev C++, and for same function it is giving error.
Is there any other way to read file name.
I WANT TO AVOID MANUAL ENTRY FOR OLD AND NEW FILE NAME
#6
Posted 24 June 2009 - 08:39 AM
#7
Posted 24 June 2009 - 08:43 AM
yes
#8
Posted 24 June 2009 - 09:23 AM
Check out the FindFirstFile() and FindNextFile() (and FindClose()) API functions. Here is an example (although using C++). I'll try to find one using C as well, if you need it. Windows SDK File System: How to search for files in a directory and subdirectories? - CodeGuru Forums
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
#9
Posted 24 June 2009 - 09:30 AM
Some resources:
MSDN documentation:
FindNextFile Function (Windows)
FindClose Function (Windows)
FindFirstFile Function (Windows)
FindFirstFileEx Function (Windows)
GetFileAttributes Function (Windows)
SetFileAttributes Function (Windows)
Example from MSDN:
Listing the Files in a Directory (Windows)
A tutorial in C:
adrianxw.dk FindFirstFile 1
MSDN documentation:
FindNextFile Function (Windows)
FindClose Function (Windows)
FindFirstFile Function (Windows)
FindFirstFileEx Function (Windows)
GetFileAttributes Function (Windows)
SetFileAttributes Function (Windows)
Example from MSDN:
Listing the Files in a Directory (Windows)
A tutorial in C:
adrianxw.dk FindFirstFile 1
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
#10
Posted 24 June 2009 - 09:34 AM
Thanks marwex
i try and let you know
i try and let you know
#11
Posted 24 June 2009 - 09:35 AM
No problem, dude. Good luck :)
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
#12
Posted 25 June 2009 - 10:15 AM
Thank you Marwex that worked
these links will help me in future also
these links will help me in future also


Sign In
Create Account


Back to top









