|
odesh wrote: can anyway shed some light ?
Class B needs a using statement.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello friends,
I have one question n my question is... How i can read data from .txt file.I have one drawing in autocad which contain all loop name as a text.If i will click on any looptext name then it will open that page..
I have file.. name is "WG_LL.txt" file at particular location.Following data are containing inside my file.
L 10011LoopO\00000001\00000001\00000001.xml
L 400142LoopO\00000001\00000008\00000042.xml
NP10033LoopO\00000001\00000001\00000003.xml
T 10022LoopO\00000001\00000001\00000002.xml
If i will click L 1001 from the Autocad drawing then it will open
" L 10011LoopO\00000001\00000001\00000001.xml" file..I know we can use "shellexecute" to open the document but i dont know how to read data.
Plz any body know then help me bcz i am new in this field..
Thanking u very much.
shah
|
|
|
|
|
Here a code snippet that might help you:
<code>
HANDLE hFile;
DWORD dwNumRead;
BOOL bTest;
char dwBuffer[256];
hFile = CreateFile("File1.txt", GENERIC_READ, FILE_SHARE_READ,NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
bTest= ReadFile(hFile, dwBuffer, sizeof(char)*256, &dwNumRead,NULL);
char seps[] = "\n\r";
char *token;
char *Lines[10];
for (int i=0;i<10;i++)
{
Lines[i] = NULL;
}
token = strtok( dwBuffer, seps );
int x = 0;
while( token != NULL )
{
Lines[x] = token;
token = strtok( NULL, seps );
x++;
}
</code>
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
« Programm3r » wrote: The only programmers that are better than C programmers
*grin* It's possible he's using C, in which case your sample is very useful. If he's using C++, I'd strongly advise against using C file handling.
Christian Graus - C++ MVP
|
|
|
|
|
Christian, don't care, it's his sig
|
|
|
|
|
I *know* it's his sig, but the code he posted is also C, and I would strongly advise against using it in a C++ program.
Christian Graus - C++ MVP
|
|
|
|
|
|
Hi Christian,
The whole " ... The only programmers that are better than C ..." is just my signature But you are right I would strongly advise against it too.
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
« Programm3r » wrote: The whole " ... The only programmers that are better than C ..." is just my signature
So why not set it apart from the rest of your post (so that folks don't take it out of context)?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
The standard C++ way is to use an ifstream. This has the advantage of providing a clean way to read the data, especially if you know exactly what format it's in.
I recommend googling for ifstream for some examples.
Christian Graus - C++ MVP
|
|
|
|
|
Shah Satish wrote: How i can read data from .txt file.
If you are using MFC, check out the CStdioFile class. If not, check out the STL's ifstream class.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi!!! Thanks for reply.
Ya..I am using MFC class.have any idea??
|
|
|
|
|
Shah Satish wrote: have any idea??
Nothing other than what I already provided.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi all,
Just a quick question, the parameter lpFileName required by the Delete Function, can or rather must it be a complete path to the file for example:
<code>
BOOL DeleteFile(
LPCTSTR lpFileName
);
lpFileName = "C:\Directory\file1.txt";
DeleteFile(lpFileName);
</code>
And what about rights to delete the file??
Thanx in advance
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
prefer full paths...
BTW, "C:\Directory\file1.txt" is not a valid path due to the \ escape character. you should write :
"C:\\Directory\\file1.txt"
|
|
|
|
|
Thank you toxcct....
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
You can also use of SHFileOperation instead DeleteFile, why?
From the MSDN:
When used to delete a file, SHFileOperation attempts to place the deleted file in the Recycle Bin. If you wish to delete a file and guarantee that it will not be placed in the Recycle Bin, use DeleteFile.
|
|
|
|
|
Thank WhiteSky for the help...
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Dear All,
I need to create an XML file from Registry. I dont know how to do this.
Registry subkeys are tagnames and registry values are tag attributes.
Kindly help me.
Thanks.
|
|
|
|
|
where's your problem exactly ? reading the registry ? or writing XML ?
|
|
|
|
|
writing XML ..
Kindly help me. Show some sample programs if you can.
thanks
|
|
|
|
|
have you already searched for an XML library ?
if so, have you tried to play with it ?
what was wrong with this[^] ?
[edit]
please indicate what you tried, where you couldn't go further, and because of what ? (post code samples if relevant).
[/edit]
|
|
|
|
|
- call regedit.exe
- export the registry
- write a program that converts the result to XML format
|
|
|
|
|
did you read the posts in the thread ?!
|
|
|
|