Showing posts with label folder. Show all posts
Showing posts with label folder. Show all posts

Wednesday, March 28, 2012

The best way to archieve this? Help please

I have an ASP.NET application running on one win2k server and it needs to
access a shared folder in other server. To access this shared folder, I have
to login with user name and password.

I used IWshRuntimeLibrary.WshNetwork() and mapped the folder to a network
drive (Y:\) in the page_load. Then I disconnected this drive in the
page_unload. I got it works but not stable. Sometimes it fails to disconnect
and to map.

thanks"dbui" <nnngoan@dotnet.itags.org.hotmail.com> wrote in
news:u6zLB9pbEHA.1408@dotnet.itags.org.TK2MSFTNGP12.phx.gbl:

> I used IWshRuntimeLibrary.WshNetwork() and mapped the folder to a
> network drive (Y:\) in the page_load. Then I disconnected this drive
> in the page_unload. I got it works but not stable. Sometimes it fails
> to disconnect and to map.

How about impersonating a user with access to that drive?

http://support.microsoft.com/defaul...b;EN-US;Q306158

--
Lucas Tam (REMOVEnntp@dotnet.itags.org.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
thanks for the link.

"Lucas Tam" <REMOVEnntp@dotnet.itags.org.rogers.com> wrote in message
news:Xns952CB1601E166nntprogerscom@dotnet.itags.org.140.99.99.130.. .
> "dbui" <nnngoan@dotnet.itags.org.hotmail.com> wrote in
> news:u6zLB9pbEHA.1408@dotnet.itags.org.TK2MSFTNGP12.phx.gbl:
> > I used IWshRuntimeLibrary.WshNetwork() and mapped the folder to a
> > network drive (Y:\) in the page_load. Then I disconnected this drive
> > in the page_unload. I got it works but not stable. Sometimes it fails
> > to disconnect and to map.
> How about impersonating a user with access to that drive?
> http://support.microsoft.com/defaul...b;EN-US;Q306158
> --
> Lucas Tam (REMOVEnntp@dotnet.itags.org.rogers.com)
> Please delete "REMOVE" from the e-mail address when replying.
> http://members.ebay.com/aboutme/coolspot18/

The best way to archieve this? Help please

I have an ASP.NET application running on one win2k server and it needs to
access a shared folder in other server. To access this shared folder, I have
to login with user name and password.
I used IWshRuntimeLibrary.WshNetwork() and mapped the folder to a network
drive (Y:\) in the page_load. Then I disconnected this drive in the
page_unload. I got it works but not stable. Sometimes it fails to disconnect
and to map.
thanks"dbui" <nnngoan@dotnet.itags.org.hotmail.com> wrote in
news:u6zLB9pbEHA.1408@dotnet.itags.org.TK2MSFTNGP12.phx.gbl:

> I used IWshRuntimeLibrary.WshNetwork() and mapped the folder to a
> network drive (Y:\) in the page_load. Then I disconnected this drive
> in the page_unload. I got it works but not stable. Sometimes it fails
> to disconnect and to map.
>
How about impersonating a user with access to that drive?
http://support.microsoft.com/defaul...b;EN-US;Q306158
Lucas Tam (REMOVEnntp@dotnet.itags.org.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
[url]http://members.ebay.com/aboutme/spot18/[/url]
thanks for the link.
"Lucas Tam" <REMOVEnntp@dotnet.itags.org.rogers.com> wrote in message
news:Xns952CB1601E166nntprogerscom@dotnet.itags.org.140.99.99.130...
> "dbui" <nnngoan@dotnet.itags.org.hotmail.com> wrote in
> news:u6zLB9pbEHA.1408@dotnet.itags.org.TK2MSFTNGP12.phx.gbl:
>
> How about impersonating a user with access to that drive?
> http://support.microsoft.com/defaul...b;EN-US;Q306158
> --
> Lucas Tam (REMOVEnntp@dotnet.itags.org.rogers.com)
> Please delete "REMOVE" from the e-mail address when replying.
> [url]http://members.ebay.com/aboutme/spot18/[/url]

Thursday, March 22, 2012

The files are downloaded with the html code at the end of them

I have a code that download files form a folder to the client:

Try
Response.AddHeader("Content-Disposition", "attachment;filename=" & strFileName)
Dim fs As FileStream = New FileStream("C:\text.txt", FileMode.Open, FileAccess.Read)
Dim fileData As Byte()
ReDim fileData(fs.Length)
Dim bytesRead As Long = fs.Read(fileData, 0, CInt(fs.Length))
fs.Close()
Response.BinaryWrite(fileData)
Catch es as Exception
lblAlert.text = "It was a problem transferring the file."
end try

The problem is that if you open the files with 'notepad' you see that the html code of the page has been incorporated to the end of the file. Something like this:

***************Beginning of the file***************
0000114099 00000 n
0000114243 00000 n
0000114317 00000 n
trailer<</Size 62/ID<79e93880650e9d343ab0837ab878f5cd><79e93880650e9d343ab0837ab878f5cd>]>>
startxref 173 %%EOF
<html>
<head>
<title>HLC Intranet - HLC Eroom</title>
***************rest of the html code***************

Somebody knows what can be? How can I takeout the html code?

Thanks,

BriegaHi,

I presume this is some code-behind code. Check if there is still some html code in your page (this is created automatically when you create a new webform in vs.net). Delete the html code and only leave the Page-directive.

I struggled with this issue also last year and this is what worked for me:


Response.Clear()
Response.ContentType = scan.ContentType
Response.BinaryWrite(scan.Document)
Response.End()

Grz, Kris.
It works!!!

The only part of your code that I don't understand is the


Response.BinaryWrite(scan.Document)

Could you tell me what that does? I've copy the code without it and it works anyway.

Regards,

Briega
Sorry I typed wrong!

What I don't understand is:


Response.ContentType = scan.ContentType

Briega
I'm sorry, I took a little snippet out of my code. scan is an instantiation of a custom made class which retrieves the binary data and it's accompanying contenttype (pdft, excell, word, ...)

You can search for the content types on the internet.

Grz, Kris.

Tuesday, March 13, 2012

The main Issue on Browse folder in Web application??

Hi,
I want to phrase my problem in a new way that the following code works well on the same system on debugging mode of the project but If I want to copy the url of the project and paste into new browser window without debugging mode, then the problem arises that Its shows progressing the browse folder dialog box does not appears any how. So If any one have the solution of my problem please reply me soon...
I written earlier on this topic shown below...
-----
I am facing a problem of browse folder. Its working fine on loacalhost but when I upload my project into my client's server, the browse folder dialog box does not appears any how. It giving no error but browser progress bar shows progressing...
Is the reason behind this is I have used Shell32.dll for browse folder.. Or there is another way of implementing browse folder functionality on my project..
Thanks
following is mine code
-----------------
Using shell32;
protected void AddFolder_Click(object sender, EventArgs e)
{
string strPath = "";
string strCaption = "Browse a directory for uploading Album.";
//DialogResult dlgResult;
string dlgResult = "";
Shell32.ShellClass shl = new Shell32.ShellClass();
Shell32.Folder2 fld = (Shell32.Folder2)shl.BrowseForFolder(0, strCaption, 0, System.Reflection.Missing.Value);
if (fld == null)
{
dlgResult = "Cancel";//DialogResult.Cancel;
}
else
{
strPath = fld.Self.Path;
lstboxFile.Items.Add(strPath);
//strPath = "albums\\MSN Home Page";
lstboxFile.Items.Add(strPath);
BaydonConstants.hif1.Add(strPath);
dlgResult = "Ok";//DialogResult.OK;
}
}

-----------------

Looks like the problem you are facing is due to security permissions in that folder, please do check on IIS folder permissions as well as the user running under IIS has enough access to that folder.

Merry Xmas


In what kind of environment are you using this? You can't use the shell classes in ASP.NET.


I am using it in a web application which have to run on LAN.

Hi,

Based on my understanding, you want to upload the whole folder and need to show the Directory OpenDialoge. If I have misunderstood you, please feel free to let me know.

As far as I know, you can't achieve this by using the codes above but it can be implemented by ActiveX which is unusual approach we use.

Instead of it, usually we useZip the files ormutiple filesupload to achieve it. There are two links as followings about uploading mutiple files.

http://www.codeproject.com/KB/aspnet/multiuploads.aspx

http://www.codeproject.com/aspnet/FlashUpload.asp

Or you can try thisscript about upload folder:http://scriptbuilders.net/files/uploadfolderaction1.0.html

Hope it helps.