Help with txt files...

Franklin
Member Posts: 253
Good morning,
I'm having problems with a txt file and do not understand the cause.
What I do is, once imported a file with a dataport, take it to a history folder and then clear the txt.
To take it a history folder I do the following:
vRutaConfiguracion: = 'C: \ test \ production \ entries';
vRutaOrigen: vRutaConfiguracion + = '\ file.txt';
vRutaDestino: vRutaNueva + = '\ file.txt;
File.Copy (vRutaOrigen, vRutaDestino)
Then I write:
OutFile.CREATE (vRutaOrigen)
(It is assumed that re-create that file, I overwrite the previous one and will remain empty)
But NAV sohows me this error:
"You can not access the file C: \ test \ production \ inputs \ file.txt"
That's just the path and I have to create file and folder permissions issues of windows is not.
I'm having problems with a txt file and do not understand the cause.
What I do is, once imported a file with a dataport, take it to a history folder and then clear the txt.
To take it a history folder I do the following:
vRutaConfiguracion: = 'C: \ test \ production \ entries';
vRutaOrigen: vRutaConfiguracion + = '\ file.txt';
vRutaDestino: vRutaNueva + = '\ file.txt;
File.Copy (vRutaOrigen, vRutaDestino)
Then I write:
OutFile.CREATE (vRutaOrigen)
(It is assumed that re-create that file, I overwrite the previous one and will remain empty)
But NAV sohows me this error:
"You can not access the file C: \ test \ production \ inputs \ file.txt"
That's just the path and I have to create file and folder permissions issues of windows is not.
0
Comments
-
you may not have blanks in the subdir if there aren't in reality.
I think you need this: 'C:\test\production\entries'.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Try the same thing with a slash instead of backslash. Does it work now?0
-
Also, if you are doing it inside the dataport, I believe it maintains a lock on the file until it's done. So you can't overwrite / change it.0
-
Which line of your code creates the error? It could already be the copy if you have programmed this inside the dataport. Try to move the code which copies and clears the file into a codeunit which first calls the dataport and then copies and clears the file - which creates another problem, because the other software which writes into this file could already have written into the file inbetween.
If another software writes to the file and assumes it does exist at all times I would not process the file directly then delete and recreate it (which might place a lock on the file for several seconds) but I would first rename the file and immediately create an empty file at the same place. Then you can do your processing on the renamed file while the other process can still write to "his" file.Frank Dickschat
FD Consulting0 -
What we do is on after we import a file. I ask if you want to delete the file & if yes then It moves the completed file to a "History" folder and deletes the orginal file from the "Working" folder.
Text Constants:
FilePath -> I:\Data Feed\History\
Text0001 -> %1 Orders Imported / Would You Like To Delete The File?
OnAfterImportRecord()
OrderCount := OrderCount + 1;
OnPostDataport()
CurrFile.CLOSE; //Close the text file once done
IF CONFIRM(Text0001,TRUE,OrderCount) THEN BEGIN //ask what the next step should be
SavedFileName := FORMAT(WORKDATE,0,'<Year4>'+'-'+'<Month Text,3>'+'-'+'<Day,2>'+'-'+DELCHR((FORMAT(TIME)),'=',':'))+'.txt'; //create a History filename with date & time stamp.
FILE.COPY(CurrDataport.FILENAME,FilePath+SavedFileName); //Copy the orig file to the History directory
ERASE(CurrDataport.FILENAME); //erase the orig file
END;0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions