I have a program that has a login form. Once the user logs in, a folder will be created in the root folder under the username. And in the program, the user will be able to create an xml document. How do I go about configuring the code below so that each xml document will be stored inside each user's respective folder instead of just hard coding?
Dim
mywriter1 = New System.Xml.XmlTextWriter("C:\Inetpub\wwwroot\FYP\admin\monitorconfig.xml", System.Text.Encoding.UTF8)
Dim mywriter1 As System.Xml.XmlTextWriter Dim userPath as String
userPath = ...whatevercodeyou used to create the folder and determine the filename ....
mywriter1 = New System.Xml.XmlTextWriter(userPath, System.Text.Encoding.UTF8)
stw wrote:Dim mywriter1 As System.Xml.XmlTextWriter Dim userPath as String userPath = ...whatevercodeyou used to create the folder and determine the filename .... mywriter1 = New System.Xml.XmlTextWriter(userPath, System.Text.Encoding.UTF8)
On another note:
Why are you doing this ? Your solution will have huge scaliability problems once your users number into the hundreds. Do not forget that you have to set each folders' attributes as well for security or other purposes and I forsee other problems --- Duplicate Folder names, Portability of Folders should hosting environment change, Granular Access Control, etc
A good Web Application doesnt try to create folders in any directories.
This may be a good time to go into Normalizations and Keys.
~Softwaremaker (BLOG) M. Twain: "I didn't have time to write a short letter, so I wrote a long one instead"
Anyway its part of my project requirement that creating folders according to users ought to be done. Hm it can't seems to work, can ya guys help?
*My login form codes
cn.ConnectionString = ConfigurationSettings.AppSettings("ConnectionString")
cn.Open()
cm.Connection = cn
cm.CommandText = "Select * From admin where username='" & username & "' and password='" & password & "'"
dr = cm.ExecuteReader()
System.Web.Security.FormsAuthentication.RedirectFromLoginPage(username,
Directory.CreateDirectory(Server.MapPath(username))
Response.Redirect("http://localhost/FYP/frmabout.aspx?Username=" + txtusername.Text)
lblerror.Text = "Incorrect username or password!"
lblerror.Text = ex.Message
* I want to configure the xml document path to be created in the user's folder
mywriter1 =
Erm nothing is wrong. I only want to know how do I actually configure the below lines of code so that the xml file would be created in the user's folder. Thanks.
Dim mywriter1 As System.Xml.XmlTextWriter
forlorn wrote:Erm nothing is wrong. I only want to know how do I actually configure the below lines of code so that the xml file would be created in the user's folder. Thanks. Dim mywriter1 As System.Xml.XmlTextWriter mywriter1 = New System.Xml.XmlTextWriter("C:\Inetpub\wwwroot\FYP\admin\monitorconfig.xml", System.Text.Encoding.UTF8)
mywriter1 = New System.Xml.XmlTextWriter("C:\Inetpub\wwwroot\FYP\" & username & "\monitorconfig.xml", System.Text.Encoding.UTF8)
are you saying some thing as simple as above?
regards, choongseng