Can two process open the text file to write | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can two process open the text file to write

Hi I have one exe which loads DLL... This DLL has opened one text file... It is not closed till exe scope of execution is not over... First of all exe loads DLL, calls one DLL function which open text file for written... This text file path is fixed and already known which does not change... Post DLL function call, exe calls another exe which inturn open same text file which DLL is opening Please note that I just wanted to write to text file and this is not issue of multithread...only one thread is there and no simultaneously write of text file will happen from DLL and second exe With this information, I have a query... When DLL function opens text file for writing, it works properly... But when exe number 2 tries to open text file for writing, it gives error code as 13 from fopen Can any one help on this ?

30th Sep 2021, 8:18 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 Answers
0
Makes sense to me.. Fair point... I think this can be confirmed by me once... Its mid night for me as of now and would try this in morning... I can try opening file from second process as read only and if it works i.e. if I get file pointer , above suggestion holds true... While opening for writting is throwing error code 13 and file pointer is not obtained. Till that time if any one have any other view , feel free to share or ask any doubt... Jay Matthews , thanks for your help and giving a way to think ahead...
30th Sep 2021, 9:47 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
To add on to last reply.... I also think that one reading and one writting from two process should be allowed.... When my exe (first process) was writing and it was trying to open from different command for reading it was allowed... When I moved writting logic to singleton class DLL called by first process exe, I am not able to open the file from first process for reading... I might be doing something wrong or missing something... I am opening file in a+ mode using fopen_s
30th Sep 2021, 9:50 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
Thank you all of you for your time and help. For me, it is working now.. I mean i can write to same file using both the process. I was using _tfopen_s and changing it to _tfopen worked for me
1st Oct 2021, 12:36 PM
Ketan Lalcheta
Ketan Lalcheta - avatar