Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

File in DB

3 views
Skip to first unread message

YW

unread,
Dec 14, 2009, 2:41:01 AM12/14/09
to
Is there an easy way to get out all files saving on SQL-DB into a windows
folder?

Luegisdorf

unread,
Dec 21, 2009, 9:10:02 AM12/21/09
to
Hi YW

Here two examples for AX 2009 how to write files into DB and write files to
file system.
All code is written from scratch and not tested. Please avoid using table
docuValue, that's just an example!


void fromFolderToDB(FilePath _path)
{
System.IO.DirectoryInfo dir = new
System.IO.DirectoryInfo(_path);
System.IO.FileInfo[] files;
System.IO.FileInfo curFile;
System.Collections.IEnumerator enumerator;

BinData binData;

DocuValue docuValue;

;
files = dir.GetFiles(_path);
enumerator = files.GetEnumerator();
while (enumerator.MoveNext())
{
curFile = enumerator.get_Current();

docuValue.clear();

binData.loadFile(curFile.get_FullName()); // get file content

docuValue.File = binData.getData();
docuValue.FileName = curFile.get_Name();
docuValue.insert(); // insert into DB
}
}


void fromDBToFolder(FilePath _path)
{
BinData binData;
DocuValue docuValue;

;
while select docuValue // load From DB
{
binData.setData(docuValue.File);
binData.saveFile(docuValue.FileName); // insert into file system
}
}

Make attention to CodeAccessPermission when reading/writing to file system
and when using CLR inside X++.

Best regards
Patrick

0 new messages