|
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.
|
|
|
|
|
IMO, you only have to test for supported extensions. Work with Path.GetExtension[^] method. You don't need to any regular expression.
Best wishes,
Navaneeth
|
|
|
|
|
Hi
I don't know how I can use a static class, that is placed in another folder from where I'm calling it.
I have the code below in default.aspx.cs, witch is placed under the folders Test1/Test2
(\WebSite12\Test1\Test2\Default.aspx.cs)
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection s = Databas.con;
}
}
The class, Databas.cs is placed in the root of the website. I get the error The name 'Databas' does not exist in the current context. I have the same problem with the global.asax, whitch is also placed in the root.
Please Help
Fia
|
|
|
|
|
The root is the wrong place to put it, in every way. There's a folder for your application code, it has to go in there.
Why would you want to return a SQLConnection into the presentation layer ?
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.
|
|
|
|
|
Hi
What I'm trying to say it that it doesn't find it, so I can't use it in the code behind.
Fia
|
|
|
|
|
Hi, thanks for your answer
I put the Databas.cs in the folder App_Code, but I couldn't use it anyway. Is there something else I have to do, then writing SqlConnection s= Databas.con.
I have it like this because I don't want to write the connection string for every page.
I have trouble with using the global.asax also, should that file also be placed in App_Code. But as I said I can't use it anyway.
Please Help
Fia
|
|
|
|
|
Hi
Sorry, I placed the Databas.cs file in the App_Data folder, but now I have it in the App_Code folder and it's working, thanks. But what about global.asax. That file is placed in the root of the website, but I can't use it anyway.
Fia
|
|
|
|
|
What do you mean you can't use it ? What do you think it's for ?
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.
|
|
|
|
|
Hi,
i have a windows services that uses a service reference to amazon web service. I have created a dll that actually has the service reference and the dll is called by my windows service. My windows service works fine. I also have a local asp.net application that uses the same dll and works great (Probably because dll and asp.net application are created on same machine). Recently, i moved the asp.net application to LAN Server. I copied the dll into bin folder. I also copied the service reference folder to bin folder and it turns out that the asp.net application is not using the service reference. It is calling my dll but the dll inturn isn't using the service reference.
Can anybody please provide help on where should i copy the service reference folder or files. or wat approach i should take to solve this issue. I googled but it seems that i am not googling appropriate keywords. Any help, link etc will be highly appreciated
Thanks
Mark
|
|
|
|