Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Hi,

My Requirement is to search .XML files from two shared paths given below which includes folder structure of 5 days .

Hide   Copy Code
string path1 = "\\sdcntprdeafil001.ukroi.org\\EAIShare\\PDCU\\OutboundArchive\\StockCR_Archive;;
string path2 = "\\sdcntprdeafil001.ukroi.org\\EAIShare\\PDCU\\OutboundArchive\\StockCR;;


File mask should be : SRCNV*_Storenumber* to be searched for each day folder.

Once the file is found it should give a hyperlink to download the file.

Can anyone please help.

Many Thanks,
Sisir
Posted
Comments
[no name] 2-Jan-16 0:27am    
Are you using windows or web application because of hyperlink?
Sisir Behera 2-Jan-16 4:07am    
Web application
[no name] 2-Jan-16 5:20am    
Can you give an example what is the rule for searching xml file(SRCNV*_Storenumber*).
Sisir Behera 2-Jan-16 5:55am    
File name basically starts with SRCNV series followed by store number.

For Example :
SRCNV868_3284_16122015160100_1.xml

SRCNV868 - File name
3284 - Store Number

So baiscally if you give a search with SRCNV*_Storenumber* , it will give list of all the SRCNV files for that date on the folder present
Sisir Behera 4-Jan-16 8:33am    
Hi All,

Below is the code which i am trying to search all the files from the shared path and also i need to download the files

<pre lang="C#">protected void Button1_Click(object sender, System.EventArgs e)
{

string search = TextBox1.Text;
string[] files = Directory.GetFiles(@"\\sdcntprdeafil01\EAIShare\PDCU\OutboundArchive\StockCR_Archive", "*.*", SearchOption.AllDirectories);
int Flag = 0;
string dir = @"\\sdcntprdeafil01\EAIShare\PDCU\OutboundArchive\StockCR_Archive";
string[] files1;
int numFiles;
files1 = Directory.GetFiles(dir);

numFiles = files.Length;
Response.WriteFile("Files searched : " + numFiles + "<br>");
for (int i = 0; i < numFiles; i++)
{


string file = files[i].ToString();

int file1 = file.IndexOf(search, StringComparison.CurrentCultureIgnoreCase);
if (file1 != -1)
{
Response.Write("<br>" + file);

Flag = 1;


}

}
if (Flag == 0)
{
Response.Write("No Matches Found");
}
}
}</pre>


Please help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900