|
Have You seen CG answer..!
show us the code ..!
How did you save it..!
May be group can help..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
modified on Tuesday, November 3, 2009 1:08 AM
|
|
|
|
|
The code for this problem is here:
I have an ASP.NET and this is the code in default.aspx:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button6" runat="server" onclick="Button6_Click" Text="Button" />
<br />
<br />
</form>
</body>
</html>
And here is the code into default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button6_Click(object sender, EventArgs e)
{
FileUpload1.SaveAs("D:\\a.txt");
}
After compiling the project, I published it as following:
clicked right mouse on it and selected "Publish Website". Then I copy published files to a folder example (a subfolder of C:\Inetpub\wwwroot). Finally, I ran IE and fill in the address: http://localhost/example/default.aspx, clicked button_6, and got the error.
I installed IIS on my local computer with version v5.1
Thanks,
|
|
|
|
|
I'm a beginner wrote: s("D:\\a.txt");
whts this..!
I used like this it worked..!
FileUpload1.SaveAs(@"C:\temp\" + FileUpload1.FileName);
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
If you answered my questions, I'd understand what your situation is, and I'd be able to give you a definitive answer. Is IIS running on your desktop, or on a remote computer ? Where did you publish your site to ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I answered your questions above.
Thanks,
|
|
|
|
|
I dont think he has the permission.!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
modified on Tuesday, November 3, 2009 1:09 AM
|
|
|
|
|
sashidhar wrote: I dont think he has the permission.!
If I don't, why it can run correctly on Visual Studio 2008?
Thanks,
|
|
|
|
|
I believe that the web server that's built in to visual studio doesn't enforce the sort of security that IIS does, simply because no-one is going to run a live website with it. Imagine if my site is on a web host that runs a lot of other sites. They are probably all going to be folders under the IIS root. So, if I were to write code that looks for files with a path starting in a .., I could try to read files that belong to another site. That's just one reason why IIS doesn't let you read or write above the root of the web application.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Your answer is absolutely right. If I save the file to one of the folders under the project, it works with IIS.
So I wonder if there is any way to write directly to another location like I did (Configure IIS for example) because when I searched information, some people say that there is a way by adding this line in web.config file between tag <system.web> and </system.web>:
<identity impersonate="true"/>
I tried, but it did not work.
Thanks for your help,
|
|
|
|
|
What abt this code..!
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button6_Click(object sender, EventArgs e)
{
FileUpload1.SaveAs("D:\\a.txt"); <big><----</big>
}
use the following code..!
FileUpload1.SaveAs(@"D:\SomeFolderName\" + FileUpload1.FileName);
Your wasting the time..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
That code placed in default.aspx.cs file is used to save a file whose path is got from FileUpload1 Control to D:\a.txt (Actually, it saves and change the original file's name into a.txt).
If I modify it as following, it works:
protected void Button6_Click(object sender, EventArgs e)
{
FileUpload1.SaveAs(Server.Map("~")+@"\a.txt"); <----
}
But I do want it to do directly on D: Drive (or another Drive, not C: Drive)
Thanks,
|
|
|
|
|
Have You tried the above code..!
Make sure a folder is created..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
Yes, I tried and it worked, but this approach is not exactly what I want. If the path is got from Server.Map("~"), I just only work with C: Drive because wwwroot folder of IIS is only placed on C:Drive. I want to work with D: Drive instead.
Thanks,
modified on Tuesday, November 3, 2009 5:39 AM
|
|
|
|
|
I'm a beginner wrote: I want to work with D: Drive instead.
Follow this steps..!
1)Create a folder myfolder in D
drive..!
try the below code ..!
FileUpload1.SaveAs(@"D:\myfolder\" + FileUpload1.FileName);
What do u mean by this..!
I'm a beginner wrote: Server.Map("~")
Server.Map is the root folder of your website..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
sashidhar wrote: FileUpload1.SaveAs(@"D:\myfolder\" + FileUpload1.FileName);
Yes, I tried the code above and that is the approach I want to do. Unfortunately, it threw an error like the question of this topic.
sashidhar wrote: Server.Map is the root folder of your website..!
Yes, it is.
Thanks,
|
|
|
|
|
Make this folder share and try it..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
Oops, I tried and this time, it worked. I have no idea.
Thanks for your help,
|
|
|
|
|
I'm a beginner wrote: Thanks for your help,
Here Its A tradition to mark it as answer if it really helps you..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
hello,
If i want that if some body have logged in on my portal with his user name and pwd.and at same time same user tries to logged in from different computer with his user name and pwd then system should tell him that "you are already logged in with this user name and pwd."
how can i achieve this in asp.net c# application.
thanks in advance.
Regards
Amit
Amit Agarwal
|
|
|
|
|
This is most frequently asked question. There is a search box on the right top corner. You will find plenty of answers if you use that.
To answer the question, you need keep a flag in the database which will be set when user logs in and unset when logs out. When a user logs in, check the status of this flag and if it is set, say that user has logged already. This method is not fully foolproof. A common problem of this approach is your flag will not reset if user closes the browser without logging out.
Hooking JS method on window close and doing AJAX request to reset the flag is one possible option. But since JS can be turned off at the client side, this method is not reliable. A better approach is to record the last activity time of the user and a database job resets the flag if current time - last activity time is greater than session expiry limit.
A combination of all these methods will work well.
Best wishes,
Navaneeth
|
|
|
|
|
thank you so much for the very nice and approchable answer.
i got two of your answers.
but
"A better approach is to record the last activity time of the user and a database job resets the flag if current time - last activity time is greater than session expiry limit."
can you please little Elaborate this approach.how to record the users last activity time.
and in the search box what will the correct keywords to find out the answer.
Thanks
Amit Agarwal
|
|
|
|
|
Amit Agarrwal wrote: how to record the users last activity time
Whenever there's a postback (ie: the user submits a form etc, clicks a button, whatever), simply call a function that updates a field in your user table with the current date/time.
|
|
|
|
|
I meant exactly what Damian said. This will allow you to identify how long a user is inactive and reset the flag if he is inactive for long time.
Best wishes,
Navaneeth
|
|
|
|
|
I have a file upload control in my application. The user can upload a file starting with alphabets as well as numerals. However, while uploading a file with numbers ,it is giving error. I have the following validation expression:
ValidationExpression="[a-zA-Z\\].*(.txt|.csv|.CSV)$"
How can I include the validation for numbers also? I tried 0-9 as below , but it didn' worked.
[a-zA-Z0-9\\]
Please help
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Why limit filenames at all ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|