18Apr2016530PMAlpeshPandhidoc
Hi all...
I am not able to form the following logic ... Please help..
In Computer, I have many pdf files . Location - D:\\UploadedFiles
All file-names are unique - I have added Current DateTime as prefix for file Name.
String File = 18Apr2016530PMabcd.pdf
String dateTime = DateTime.UtcNow.Date.ToString("ddMMMyyyy") + DateTime.Now.ToShortTimeString();
String FileName = datetime + File;
----------------
SQL Server –
| ColumnsNames | DataType |
|
| ID | Numeric(18,0) | PK ;Not Null; Auto increment |
| File Name | Varchar(500) | PK, Unique ; Not null |
| Status | bit | 1-Active ; 0-InActive |
| Uploaded By | Numeric(18,0) | Not Null |
| Uploaded Date | Datetime | Not null (Default – Current Date) |
----------------
On GridView,I want the output as follows –
| FileName | UploadedBy | UploadedDate |
|
|
| 18Apr2016530PMabcd.pdf
| Sanjay.Sharma | 1-JAN-2016 | View | Delete |
| 18Apr2016530PMWelfare.pdf
| Mahesh.Bhatt | 5-JAN-2016 | View | Delete |
Logic – I need to get list of files from path D:\\UploadedFiles
I need to check whether all file names are present in database or not.
If not, then I have to delete those records from the database.
Please guide…
Riddhi ValechaPosted Apr 22, 2016, 1:20 AM
String[] filenames = Directory.GetFiles(@"D:\");
foreach (string item in filenames)
{
string filename = Path.GetFileName(item);
// Check if filename exists in the sql server column or not.
//if no, then delete file from directory.
}
-----------
The requirement is - I need to check that files present in directory, must be there in SQL Server column.
Eg - Filename - 1jan2016560pmabcdef.pdf - must be present in directory and this name must be there in sql server column.
How to do this ?
There will be thousands of files... so... I need a faster solution....
Rahul ChavanPosted Apr 20, 2016, 5:55 AM
Nishant MittalPosted Apr 20, 2016, 4:16 AM
Riddhi ValechaPosted Apr 20, 2016, 4:12 AM
Nishant MittalPosted Apr 20, 2016, 3:19 AM
Riddhi ValechaPosted Apr 20, 2016, 3:00 AM
Nishant MittalPosted Apr 20, 2016, 2:51 AM
Riddhi ValechaPosted Apr 20, 2016, 2:49 AM
Nishant MittalPosted Apr 20, 2016, 2:26 AM
Riddhi ValechaPosted Apr 20, 2016, 2:22 AM
Nishant MittalPosted Apr 19, 2016, 11:27 PM
// Put all file names in root directory into array. string[] array1 = Directory.GetFiles(@"C:\");