Get the file list under the server folder

Source: Internet
Author: User
// Time Selected
String Strdatenow;
Strdatenow = Calendar1.selecteddate. tow.datestring ();
// File name corresponding to the time
String Strrelfilename =   " Yujing- "   + Strdatenow +   " . Rel " ;
String Strjpgfilename =   " Disaster Warning chart- "   + Strdatenow +   " . Jpg " ;
// Whether a file exists
Bool Isexistrelfile =   False ;
Bool Isexistjpgfile =   False ;

// Prompt information
System. Text. stringbuilder strmsg =   New System. Text. stringbuilder ( " Query Information: <HR color = Red> " );

// File directory and name
String Strcurdir, filename, fileext;
// The default value is the directory of the current page.
Strcurdir = Server. mappath ( " Data/historymap/ " );

Fileinfo fi;
Directoryinfo dir;
// Create a directory reference object for the current directory
Directoryinfo dirinfo =   New Directoryinfo (strcurdir );

// Cyclically identifies objects of a specified date
Findfile # Region Findfile
Foreach (Filesysteminfo FSI In Dirinfo. getfilesysteminfos ())
{
Filename =   "" ;
Fileext =   "" ;
If (FSI Is Fileinfo)
{
Fi = (Fileinfo) FSI;
// Get File Name
Filename = Fi. Name;
// Get the file extension
Fileext = Fi. extension;
If (Fileext =   " . Rel " )
{
If (Filename = Strrelfilename)
{
Isexistrelfile= True;
}
}
If (Fileext =   " . Jpg " )
{
If (Filename = Strjpgfilename)
{
Isexistjpgfile= True;
}
}

}
Else // Otherwise, it is a directory.
{
Dir = (Directoryinfo) FSI;
// Get directory name
Filename = Dir. Name;
// Set the file extension to "folder"
Fileext =   " Folder " ;
}
}
# Endregion
// If both files exist
If (Isexistrelfile && Isexistjpgfile)
{
Strmsg. append (strdatenow +   " Warning chart query successful! " );
Strstate. Text = Strmsg. tostring ();
// Controls the map window to display the historical graph.
Showhistorymap # RegionShowhistorymap
//Code to be added
# Endregion
}
Else
{

Strmsg. append ( " Not found "   + Strdatenow +   " Warning chart! " );
Strstate. Text = Strmsg. tostring ();
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.