hello everybody..

I have a table which contains all the info about a file i.e its id, name, size, createddt and modifieddt.
now i need to copy all the files(file content) to a local drive.
Gotta do this in c# console application. Can anybody help me?

Recommended Answers

All 3 Replies

Select the data from the database, create a file with the correct name and write the data to it. You will need to decide what kind of writer based on the data type ie. Binary or Plain Text

You can use methods on the File class to do things like SetCreationTime and SetLastWriteTime.

hey Ketsuekiame, thanks for the reply .. let me be more specific.. for instance when a file.docx is uploaded.. the file is saved under D:/Folder and the details of the file are inserted in the sql db.. now in E:/folder i need to copy all the files from D:/folder based on the folder name and time of upload.. once a file is copied to E:/folder it shouldn't copied again.can yu get my point?

If the file contents themselves are not stored in the database and you don't have a service that has access to the local file system then you will not be able to retrieve the file data.

Otherwise you just need to read the database to find the file location and return the byte array you get from reading the file back to the caller of the service. Then once you have done that you would remove the file from the local disk and the database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.