Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #21 (permalink)  
Old March 7th, 2007, 03:16 PM
Authorized User
 
Join Date: Mar 2007
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar and click,
Thank you so much for your help.
Please don't hesitate to make suggestions if you see something wrong with my code or think I should improve it.
Next thing I need to do, is create a 'view' column, where the user can look at the pdf in the browser instead of downloading it.
Is't OK if I post here if I have problems with displaying the pdf's in the browser?

  #22 (permalink)  
Old March 7th, 2007, 05:39 PM
Authorized User
 
Join Date: Mar 2007
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ki Ki,
Ok so im wondering,
Are the directories with the files going to be subdirs of the main directory?
Are they going to be readable by iis/web?

Im just wondering because this all has me intrigued. I think your going about this very creatively, but I think if the two questions I asked are yes, this code can be greatly simplified.

To the point where I think you would be surprised at its simplicity.

To my understanding this is what it does:

I have a part number. That part number tells me the subdirectory, its subdirectory, and finally the part.pdf to pull up.

If I type it in, it splits it up, and looks for the pdf.

If it finds it, it displays it (or downloads it).

The folders that the files are contained in are sub folders of this directory. so

f:\livewebsites\myProject\111\1234\1112.pdf

is a fake, but plausable 'physical directory' and virtually its reachable via:

www.mysite.com/111/1234/1112.pdf

Correct? Let me know if I have this correct. If I do, I can help you create a simpler version in just a few minutes.

Ciao
Clickage

  #23 (permalink)  
Old March 7th, 2007, 06:01 PM
Authorized User
 
Join Date: Mar 2007
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, so, this works for me quick and simple like.

VB code:
---------------------------------------------------------
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        doSplit()
    End Sub
    Private Sub doSplit()
        Dim startDir As String = TextBox1.Text
        Dim FinalDir As String = Mid(TextBox2.Text, 1, 3)
        Dim filename As String = Mid(TextBox2.Text, 4, 4)
        Dim myPath As String = startDir & "/" & FinalDir & "/" & filename & ".pdf"
        If System.IO.File.Exists(Server.MapPath(myPath)) Then
            myLink.text = "click here to view the pdf"
            myLink.navigateUrl = myPath
        Else
            myLink.text = "File not found"
            myLink.navigateurl = ""
        End If
    End Sub
--------------------------------------------------
Page code:
--------------------------------------------------
 <asp:TextBox ID="TextBox1" runat="server" Width="42px">111</asp:TextBox>-<asp:TextBox ID="TextBox2" runat="server" MaxLength="7" Width="74px">2223333</asp:TextBox>
        Prod Number<br />
        <asp:Button ID="Button1" runat="server" Text="Button" /><br />
        <br />
        &nbsp;<asp:HyperLink ID="myLink" runat="server" Width="389px">HyperLink</asp:HyperLink>
------------------------------------------------
Directory Structure starting at root directory
111 'directory off root
222 'directory off root
  333 'directory off 222
    4444.pdf 'file in direcotyr '333'
---------------------------------------------

It creates a link to this file they are looking for. You could easily load it in an iframe, or current window or whatever. The files above are located off of the folder the aspx page is running in.

Please, let me know if this helps.


  #24 (permalink)  
Old March 7th, 2007, 06:05 PM
Authorized User
 
Join Date: Mar 2007
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi click,

Thank you for your suggestion. The link is 'alive' with back or forward slash...I guess it doesn't matter.
I am not using relative path right now because i am just 'playing' with this. I want to see if i am able to make it work before I add it to my project. On the other hand, what I'd like, is to read files in folders that are not on the webserver(intranet actually).
I tried to connect to another server, but I was able to do it only from the application on my machine. When I moved the project files to the intranet server and used the browser I was not able to access a server that was different from the intranet server.
Maybe I should open another question regarding this problem????
------------------------------------------------------------------------
You can actually look to see if a file exists on another servre, and it doesnt even have to be your server, but to do it you need to use the webrequest object. I have some code for that too at home i used to download every photo a website had for every product it had:)

It downloaded 200k photos in like 2 days, just opening remotely and saving locally.

I can look for that code.





  #25 (permalink)  
Old March 8th, 2007, 02:31 PM
Authorized User
 
Join Date: Mar 2007
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi click,
I have to 'digest' your suggestions first before I get back to you...probably with a lot of questions :-)
I won't have too much time today but hopefully tomorrow.
Grazie and Ciao

  #26 (permalink)  
Old March 8th, 2007, 03:30 PM
Authorized User
 
Join Date: Mar 2007
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is an excerpt from some code I used to pull a remote xml to my server for parsing. It may be of use accessing remote files for you.

network credentials are only needed if the folder your looking at is password protected.

Dim nc As NetworkCredential = New NetworkCredential("username", "passw0rd")
            Dim fetch As New WebClient
            fetch.Credentials = nc


            Dim createDate As Date
            Dim checkDate As Date

            fetch.DownloadFile(remoteUrl, "savedfile.pdf")

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a text file using hyperlink in a gridview absu General .NET 1 March 6th, 2009 02:03 AM
HyperLink in a gridview contro to open word docmen Otoniel ASP.NET Espanol 0 October 7th, 2008 01:11 AM
Get GridView Cell Value Based on GridView Column stublair C# 2008 aka C# 3.0 0 September 4th, 2008 08:30 AM
Using Hyperlink field in GridView asp_convert ASP.NET 2.0 Basics 2 February 7th, 2007 07:33 PM
hyperlink pab006 Classic ASP Basics 5 December 17th, 2003 10:33 AM



All times are GMT -4. The time now is 11:05 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.