I have just made a quick import of some files, I have done it like this - hope it helps:
If you don't want to hard code the path to your folder 'ReadFlatFiles' you have to create a parameter field where appropriate, lets say on table 'FlatFileTable', so the user or administrator are able to enter the path. For that you need to define a field on table FlatFileTable of type 'Filepath'. Create a form with the table FlatFileTable as datasource. Remember to create element method filePathLookupTitle: FilePath filePathLookupTitle() { return ""; //This method is called from outside the form, from the formhelp on the EXDT } Now you have the filepath! Create a class with a method called 'readfile' void readfile(filename _filename) { boolean emptyFile = true; ; fileRead = this.OpenAsciiFile(_filename, "R"); ttsbegin; while(fileRead.status() == IO_Status::OK) { c = fileRead.read(); if (conlen(c)) { emptyFile = false; this.insertRecord(c); numberOfRecords++; } } if (emptyFile) { if (!this.warningFileEmpty()) throw error('@SYS62664'); } ttscommit; fileread = null; } AsciiIo openAsciiFile(FileName _filename,Str _mode) { AsciiIo FileOpen; ; FileOpen = new AsciiIo(_filename,_mode); if (FileOpen.status() != IO_Status::OK) { throw Error("@SYS19358"+_filename); } FileOpen.inRecordDelimiter('\r\n'); FileOpen.inFieldDelimiter(';'); return FileOpen; } The method insertRecord() is where you transfer data from container to Axapta table(s). I know it works, but I admit I didn't use winapi - sorry :-) Regards Irving --- In Axapta-Knowledge-Village@yahoogroups.com, "gurazadasr" <[EMAIL PROTECTED]> wrote: > > Hello, > My requirement is to remove the hardcoded directory path from the > code while reading an flat file in to the system and to read all the > files which are contained in that particular folder for example if I > have a folder by name 'ReadFlatFiles' which contains 10 flat files, I > want to read all the files one by one without hardcoding the file name > at the same time I should not specify any specific directory name like > C:\\...or D:\\ i.e just by mentioning the folder name, I should able to > read all the files contained in that folder. > I heard that it can be done through WinAPI classes, but I > am not sure whether it can be done through it or not also till now I > did not work on those classes, if you have any sample code or any > suggestions on WinAPI class or to solve the above problem are greately > welcome. > > Regds > SG > ------------------------ Yahoo! Groups Sponsor --------------------~--> Make a difference. Find and fund world-changing projects at GlobalGiving. http://us.click.yahoo.com/jy2rEC/PbOLAA/cosFAA/kGEolB/TM --------------------------------------------------------------------~-> Sharing the knowledge on Axapta. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/Axapta-Knowledge-Village/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/