[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

Find a folder path from solution explorer in a web application

Hi experts,

in my web application in solution explorer i have 5 folders like product,order,item,purchase,sell
and inside each folder there is xml like as

- <Connection>
- <databaseserver name="test">
  <server>admin</server>
  <database>documentation</database>
  <uid>sa</uid>
  <password>123</password>
  </databaseserver>
  </Connection>


Now i have a drop down at front end in there are name like product,item,order.
on selection of any item i have to check weathere that folder exists or not.
and if exists then find the databasename,servewr,uid and password by using coding

pls help me ASAP.
0
ASINGH1974
Asked:
ASINGH1974
  • 2
1 Solution
 
Anurag AgarwalPython DeveloperCommented:
In NameSpace System.IO Use
FILE.Exists("FIle Path")
this will return bool value
 
Anurag
0
 
Anurag AgarwalPython DeveloperCommented:
Sorry, you need to check for folders. Use this

Directory.Exists("Folder path")
 
Anurag
0
 
sunithnairCommented:
Try this
ASPX
 
<asp:DropDownList ID="ddlFolders" runat="server" OnSelectedIndexChanged="ddlFolders_SelectedIndexChanged">
    <asp:ListItem Value="product" Text="product"></asp:ListItem>
    <asp:ListItem Value="order" Text="order"></asp:ListItem>
    <asp:ListItem Value="item" Text="item"></asp:ListItem>
    <asp:ListItem Value="purchase" Text="purchase"></asp:ListItem>
    <asp:ListItem Value="sell" Text="sell"></asp:ListItem>
</asp:DropDownList>
 
CODEBEHIND
    protected void ddlFolders_SelectedIndexChanged(object sender, EventArgs e)
    {
        if(System.IO.Directory.Exists(Server.MapPath("~/" + ddlFolders.SelectedValue)))
        {
            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            xmlDoc.Load(Server.MapPath("~/" + ddlFolders.SelectedValue));
            string databaseserver = xmlDoc.SelectSingleNode("//databaseserver").Attributes["name"].Value;
            string server = xmlDoc.SelectSingleNode("//server").Value;
            string database = xmlDoc.SelectSingleNode("//database").Value;
            string uid = xmlDoc.SelectSingleNode("//uid").Value;
            string password = xmlDoc.SelectSingleNode("//password").Value;
        }
    }

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now