Erasing a file with full path - slash problems
andy76
Member Posts: 616
Hello,
I have to delete a file in a full path position, for example,
'C:\Documents and Settings\pippo\Documenti\WindowsCE My DocumentsReadings.txt'
I have the error Syntax error and the file is not deleted.
Trying to make a message with 'C:\Documents and Settings\pippo\Documenti\WindowsCE My DocumentsReadings.txt' I see that slash are considered as line feeds. I don't know if this is the real problem but I ask you how the syntax of the full path should be.
Thank you
I have to delete a file in a full path position, for example,
'C:\Documents and Settings\pippo\Documenti\WindowsCE My DocumentsReadings.txt'
I have the error Syntax error and the file is not deleted.
Trying to make a message with 'C:\Documents and Settings\pippo\Documenti\WindowsCE My DocumentsReadings.txt' I see that slash are considered as line feeds. I don't know if this is the real problem but I ask you how the syntax of the full path should be.
Thank you
0
Comments
-
are your trying to delete or make a message? or both? where are you deleting this from?0
-
This is the code:
Dataport - OnPostDataport()
MESSAGE('C:\Documents and Settings\pippo\Documenti\WindowsCE My Documents\Readings.txt');
IF ERASE('C:\Documents and Settings\pippo\Documenti\WindowsCE My DocumentsReadings.txt') THEN
MESSAGE('Pesature importate e file cancellato')
ELSE BEGIN
MESSAGE('Errore nella cancellazione del file: ' + GETLASTERRORTEXT);
CLEARLASTERROR;
END
---
I have syntax error also writing
IF ERASE(CurrDataport.FILENAME) THEN
MESSAGE('OK')
ELSE BEGIN
MESSAGE('Error: ' + GETLASTERRORTEXT);
CLEARLASTERROR;
END
Thank you0 -
if filename & message are always a contant then make it a text constant and use
message('%1',MyTextConstant);
see pic0 -
I tried again but I have the error blank without any description
ERASE = false and GETLASTERROR = '' blank...What is the problem? Navision can not delete the folder of Active Sync syncronized with the PDA?
Thank you0 -
With your advice to use a text constant the file is deleted correctly...
but I would like to read the path from a variable field...Isn't it possible?0 -
MyVar := 'C:\\Dokumente und Einstellungen\\Rene\\Desktop\\neu.txt';
erase(MyVar);Do you make it right, it works too!0 -
andy76 wrote:I have syntax error also writing
IF ERASE(CurrDataport.FILENAME) THEN
MESSAGE('OK')
ELSE BEGIN
MESSAGE('Error: ' + GETLASTERRORTEXT);
CLEARLASTERROR;
END
I doubt it will ever not be OK unless something wierd is happening.
in regards to syntax - you should always post your error message - it helps alot
looks like you're doing an else begin without a then beginIF ERASE(CurrDataport.FILENAME) THEN BEGIN MESSAGE('OK'); END ELSE BEGIN MESSAGE('Error: ' + GETLASTERRORTEXT); CLEARLASTERROR; END;
Does it work without a close????
CurrFile.CLOSE;
Personally I like to use a confirm messageOnPostDataport() CurrFile.CLOSE; IF CONFIRM('Would You Like To Delete The File,TRUE) THEN BEGIN SavedFileName := FORMAT(WORKDATE,0,'<Year4>'+'-'+'<Month Text,3>'+'-'+'<Day,2>')+'.txt'; FILE.COPY(CurrDataport.FILENAME,FilePath+SavedFileName); ERASE(CurrDataport.FILENAME); END;
What mine does is delete the orig file from it's orig location but saves a copy in another folder called 'Completed Imports' using the date as it's new name.
filepath= I:\Internet Data Feed\Completed Import\
each person does it there own way (here's the same code without the bells n' whistles)OnPostDataport() CurrFile.CLOSE; IF CONFIRM('Would You Like To Delete The File,TRUE) THEN BEGIN ERASE(CurrDataport.FILENAME); END ELSE BEGIN MESSAGE('File %1 not deleted',CurrDataport.FILENAME); END;0 -
solved, thank you very much Savatage.0
-
Hello everyone,
I return on a my previous post that was solved more than 3 years ago.
Now I have again the problem on another development/customer.
I pass all the full path + file name to function ERASE but FILE.ERASE return false and don't delete the file.
I cannot insert the entire name of the file in a text constant because:
- the full path is a setup table so can be changed and edited
- the name of the file is variable because the file in the directory have name that continues to change (with a progressive number).
So I ask you how I can solve this in a clever way.
Thank you0 -
The file must be closed? Or is it closed automatically?
In NAV 5.0 sp1 there is not FILE.CLOSE function?
Thank you0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions