Folder all images get in asp.net :
Folder all images get in asp.net :
aspx:cs
public void getAllImages()
{
string SourceLocation;
//Image Folder
SourceLocation="D:\Projects\Sample\source";
DirectoryInfo dir = new DirectoryInfo(SourceLocation);
FileInfo[] file = dir.GetFiles();
StringBuilder sb = new StringBuilder();
StringBuilder sbFrontImageName = new StringBuilder();
StringBuilder sbbakImageName = new StringBuilder();
bool frontImgName, bakImageName;
foreach (FileInfo file2 in file)
{
if (file2.Extension == ".tif")
{
string fname = file2.ToString();
//Finding Image Name Front or Back Using Contains
//Sample_front_4.tif
//Sample_back_4.tif
frontImgName = fname.Contains("front");
bakImageName = fname.Contains("back");
string imgName = file2.ToString();
if (frontImgName == true)
{
sbFrontImageName.AppendLine(SourceLocation + "\\" + fname);
}
else
{
bakImageName = fname.Contains("back");
if (bakImageName == true)
{
sbbakImageName.AppendLine(SourceLocation + "\\" + fname);
}
}
}
}
string ImgFrontTestINP, ImgBackTestINP;
ImgFrontTestINP = SourceLocation + "\\" + "Test.inp";
ImgBackTestINP = SourceLocation + "\\" + "Test_back.inp";
System.IO.File.WriteAllText(ImgFrontTestINP, sbFrontImageName.ToString());
System.IO.File.WriteAllText(ImgBackTestINP, sbbakImageName.ToString());
}
Writting File :
Front Image Name written NotePad Test.inp:
----
Sample_front_1.tif
Sample_front_2.tif
Sample_front_3.tif
Sample_front_4.tif
Sample_front_5.tif
Back Image Name written NotePad Test_bak.inp:
----
Sample_back_1.tif
Sample_back_2.tif
Sample_back_3.tif
Sample_back_4.tif
Sample_back_5.tif
No comments:
Post a Comment