Access text file
Ashu_bhatt
Member Posts: 28
Hi All,
Is there anyway of accessing a text file filename by just knowing the initials of file name. Say for example i want to access all files starting with name PDMS in a predetermined folder and then i want to rename it.
Say if i have following files
PDMS_20070206_1325_1.TXT
PDMS_20070206_1327_1.TXT
PDMS_20070206_1019_1.TXT
Thanks
Is there anyway of accessing a text file filename by just knowing the initials of file name. Say for example i want to access all files starting with name PDMS in a predetermined folder and then i want to rename it.
Say if i have following files
PDMS_20070206_1325_1.TXT
PDMS_20070206_1327_1.TXT
PDMS_20070206_1019_1.TXT
Thanks
0
Comments
-
I think you might want to have a look at the File record. This can be used to find files. For your case it would be something like:
Files.SETRANGE(path,'c:\import\');
Files.SETRANGE("Is a file",TRUE);
IF Files.FIND('-')
REPEAT
UNTIL Files.next = 0;
This will go through all the files in the folder. If you want to only see files that have a specific string, either specifiy a filter on the Name field or use the strpos function.
Remco0 -
Thanks that answers my question.
But i have to rename file also but file table is read-only. :-s0 -
Create a variable of type file
File.Rename(OldName,newName);0 -
It says that file table is read-only0
-
OK there is a misunderstanding here - some file functions are hidden by the invisible object "file". Actually it's not so invisible, it's in the F5 menu, in all uppercase (FILE).
Therefore never create a variable that's called File...
So if your variable is Files and not File then File.RENAME(old, new) will wotk (with full path).
BTW I found this topic by chance because I have to scan the contents of a directory and to me the File table always shows empty on forms and it's COUNT is 0 ... I didn't understand it... but I tried it like in this topic, using just FIND/NEXT and apparently that works. Weird. It's clearly not like f.e. the Date table.0
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