cancelar
Mostrando los resultados de 
Buscar en lugar de 
Quiere decir: 

File Error

Hi everybody,

 

I have a problem, I tried to do a file to save some parameters from Network Analyzer (R&S ZNB8) to my computer.

However, I have this error :

 

"NON-FATAL RUN-TIME ERROR:   "Test1.c", line 370, col 34, thread id 0x0000125C:   Library function error (return value == 0 [0x0]). (ENOENT) No such file or directory"

 

I tried a lot of new code to delete this error but I didn't success.

Somebody know how to delete this error?

 

"FILE* testsauvegarde = NULL;

testsauvegarde = fopen("testsauvegarde.txt", "r+");
return 0;"

 

My error comes from red part.

0 kudos
Mensaje 1 de 19
6.226 Vistas

It is maybe not a problem of your code - the file you specify does not exist...

Or maybe it exists but not in the current directory, so it is better to specify the full path name, not just the file name

...and if the file does not exist and you want to create a new file, you should specify another mode, e.g., 'w+' instead of 'r+'

0 kudos
Mensaje 2 de 19
6.225 Vistas

Thank you Wolfgang!

How can I specify the full path name while in fopen function you need to specify only the file name ?

I created the file before run the code, so I think it's not necessary to write "w+" mode, no?

Thank you again!

0 kudos
Mensaje 3 de 19
6.221 Vistas

If the file exists you do not need to create it, so 'r+' is fine.

 

There are several ways of how to obtain a path name, you can do it manually ("C:\\My Documents\\my filename.txt") or using, e.g., a file popup, or the function MakePathname (); the latter two methods take care about the backslashes, in the first you have to remember to replace single backslashes by double backslashes.

 

0 kudos
Mensaje 4 de 19
6.220 Vistas

By using the function "MakePathname ("Z:\\.....", "testsauvegarde.txt", pathname);" I have always the same problem...

0 kudos
Mensaje 5 de 19
6.214 Vistas

What do you mean by 'the same problem'?

 

You should have something like

 

file_name [ MAX_PATHNAME_LEN ] = ""; 

 

MakePathname ( "c:\\", "myfile.txt", &file_name );

 

or   

 

GetProjectDir ( &path_name );

MakePathname ( path_name, "myfile.txt", &file_name );

 

and then

 

fopen ( file_name, "r+" );

0 kudos
Mensaje 6 de 19
6.210 Vistas

This is the same error that "No such file or directory".

I tried the second way :

GetProjectDir ( &path_name );

MakePathname ( path_name, "testsauvegarde.txt", &testsauvegarde );

testsauvegarde=fopen("testsauvegarde.txt", "r+");

0 kudos
Mensaje 7 de 19
6.208 Vistas

oh... Emoticono sorprendido what is the purpose of calling MakePathname in your case - you do not use the generated path name... have a look at the differences between your code and mine...

0 kudos
Mensaje 8 de 19
6.206 Vistas

The purpose is to do understand to the computer that I have to save parameters on this file with the path that I gave...

What was your purpose?

0 kudos
Mensaje 9 de 19
6.209 Vistas

ok, to put it more clearly, in your case the call to MakePathname is useless because you do not make use of the result.

 

The result of

int MakePathname (char directoryName[], char fileName[], char pathname[]);

is the character array pathname, which you happen to call testsauvegarde; however, in the next line you use the constant "testsauvegarde.txt".

 

You should have written fopen ( testsauvegarde, "r+' );

0 kudos
Mensaje 10 de 19
6.207 Vistas