Solved

Refresh Link in Internet Explorer

Posted on 2003-11-18
17
849 Views
Last Modified: 2006-11-17
I have an app that converts files to a pdf and places them in a folder on a network.  These folders are linked to our intranet.  The problem right now is that the link does not refresh itself, it has to be done manually.  Is there  a way to programatically have Internet Explorer refresh the links to thes files?
0
Comment
Question by:PsychoDazey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
  • +3
17 Comments
 
LVL 5

Expert Comment

by:mondayblueboy
ID: 9771739
0
 
LVL 8

Expert Comment

by:Dranizz
ID: 9772110
<META HTTP-EQUIV=Refresh CONTENT="20; URL=http://www.bob.com/">
0
 
LVL 6

Expert Comment

by:zrh
ID: 9773389
What do you mean by refresh the links?  Do you want the page to refetch (retrieve a fresh copy), or refresh?  Or do you want to have the links get updated href's without reloading the page?

ZRH
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 6

Author Comment

by:PsychoDazey
ID: 9773867
Right now if we replace a file (or add a file for that matter) the owner of that page has to reset the link because it is broken once the file is removed (or not there when a new file is added).  I want the page to automatically update so it has hyperlinks to all of the documents in that folder.
0
 
LVL 6

Expert Comment

by:zrh
ID: 9773998
Well, you could try FrontPage Extensions, or you could enable Directory Browsing in IIS.  (Or you could wait until I finish my file browser web control :))  There probably won't be an *easy* solution unless you use the two aforementioned.  I'll have to think about it..

Hope that helps some,
ZRH
0
 
LVL 12

Expert Comment

by:roverm
ID: 9777273
How about let all links point to a general APSX page, passing the image as parameter.
Then in that ASPX page you can look for the image using the System.IO namespace to browse through the folders.

D'Mzz!
RoverM
0
 
LVL 6

Author Comment

by:PsychoDazey
ID: 9779186
let me look into the front page extensions, I hadn't thought about that.
I'll get back to you.
Thanks all
0
 
LVL 6

Accepted Solution

by:
zrh earned 250 total points
ID: 9781017
You could do the idea roverm suggested, it might be more flexible to your needs too.  If you need help implementing it I'll help.
Along the same lines you could implement a HttpHandler, so you could do your links like:

http://www.yoursite.com/docs/<someid>

The <someid> would be a reference assigned permanently to that document, the HttpHandler would handle the request, and use that id to lookup the appropriate file in the filesystem, or share, or wherever, it could even be generated on the fly using a database, or etc.  That way you could separate the interface from the implementation. (always good idea)
again, I'll help if you need it.

Hope that helps,
ZRH
0
 
LVL 12

Assisted Solution

by:roverm
roverm earned 250 total points
ID: 9781278
Here's an example:

Add this to your code behind:

Imports System.IO

Put this in your page_load:

        Dim sDoc As String = Request("doc")
        Dim sFolders As String = GetAllFolders(Server.MapPath("./"))
        If sFolders <> "" Then
            Dim arr() As String = Split(sFolders, "|")
            Dim sResult As String = ""
            For i As Int16 = LBound(arr) To UBound(arr)
                sResult = SearchForFile(arr(i), sDoc)
                If sResult <> "" Then Exit For
            Next
            If sResult <> "" Then
                Response.Write("Found: " & sResult)
            Else
                Response.Write("File not found!")
            End If
        Else
            Response.Write("No folders found!")
        End If

As you can see I put a request variable in sDoc. So when calling this page it should be something like:
Server.Transfer("getdocument.aspx?doc=YOURDOCUMENT.DOC", False)

Then add these functions:

    Private Function GetAllFolders(ByVal sPath As String, Optional ByVal sSub As String = "") As String
        Dim dirroot As DirectoryInfo = New DirectoryInfo(sPath)
        If Not dirroot.Exists Then
            'folder not found!!
            Return ""
        End If
        Dim sResult As String = ""
        Dim sSubFolder As String
        Dim dirs As DirectoryInfo() = dirroot.GetDirectories("*.*")
        For Each fld As DirectoryInfo In dirs
            sResult += fld.FullName & "|"
            sSubFolder = sSub & "\" & fld.Name
            If fld.GetDirectories("*.*").Length > 0 Then
                sResult += GetAllFolders(fld.FullName, sSubFolder)
            End If
        Next
        Return sResult
    End Function
    Private Function SearchForFile(ByVal sFolder As String, ByVal sFile As String) As String
        Dim dirroot As DirectoryInfo = New DirectoryInfo(sFolder)
        If Not dirroot.Exists Then
            'folder not found!!
            Return ""
        End If

        Dim fls As FileInfo() = dirroot.GetFiles("*.*")
        If fls.Length > 0 Then
            For Each fl As FileInfo In fls
                If LCase(fl.Name) = LCase(sFile) Then
                    Return fl.FullName
                End If
            Next
        End If
        Return ""
    End Function

They will speak for themselves... ;-)
But if you need more information just let me know.

D'Mzz!
RoverM
0
 
LVL 12

Expert Comment

by:roverm
ID: 9781356
Oh, forgot to mention that this line

Dim sFolders As String = GetAllFolders(Server.MapPath("./"))

initializes the root folder from where to search.
All subfolder will be included automaticly.

D'Mzz!
RoverM
0
 
LVL 6

Expert Comment

by:zrh
ID: 9781509
Quoted from above, in c#
-------------------------------------
Here's an example:

Add this to your code behind:

using System.IO;

Put this in your page_load:

        string sDoc = Request["doc"];
        string sFolders = GetAllFolders(Server.MapPath("./"));
        if(!sFolders.Equals(String.Empty)) {
            string[] arr = sFolders.Split({'|'});
            string sResult = "";
            for(int i= arr.GetLowerBound(0), top = arr.GetUpperBound(0); i < top; i++) {
                sResult = SearchForFile(arr[i], sDoc)
                if(!sResult.Equals(String.Empty))
                    break;
            }

            if(!sResult.Equals(String.Empty)) {
                Response.Write("Found: " + sResult);
            } else {
                Response.Write("File not found!");
            }
        } else {
            Response.Write("No folders found!");
        }

As you can see I put a request variable in sDoc. So when calling this page it should be something like:
Server.Transfer("getdocument.aspx?doc=YOURDOCUMENT.DOC", false);

Then add these functions:
    private string GetAllFolders(string sPath) {return GetAllFolders(sPath, "");}
    private string GetAllFolders(string sPath, string sSub) {
        DirectoryInfo dirroot = new DirectoryInfo(sPath);
        if(!dirroot.Exists()) {
            // folder not found!!
            return "";
        }
        string sResult = "";
        string sSubFolder;
        DirectoryInfo[] dirs = dirroot.GetDirectories("*.*");
        foreach(DirectoryInfo fld in dirs) {
            sResult += fld.FullName + "|";
            sSubFolder = sSub + "\" + fld.Name;
            if(fld.GetDirectories("*.*").Length > 0) {
                sResult += GetAllFolders(fld.FullName, sSubFolder);
            }
        }
        return sResult;
    }

    private string SearchForFile(string sFolder, string sFile) {
        DirectoryInfo dirroot = new DirectoryInfo(sFolder);
        if(!dirroot.Exists()) {
            //folder not found!!
            return "";
        }

        FileInfo[] fls = dirroot.GetFiles("*.*");
        if(fls.Length > 0) {
            foreach(FileInfo fl in fls) {
                if(fl.Name.ToLower().Equals(sFile.ToLower())) {
                    return fl.FullName;
                }
            }
        }
        return "";
    }

Hope that helps,
ZRH
0
 
LVL 12

Expert Comment

by:roverm
ID: 9781577
ZRH: Can I contact you if I want some code translated from VB to C#?? ;-)
0
 
LVL 6

Expert Comment

by:zrh
ID: 9781653
Roverm: Sure :)
0
 
LVL 8

Expert Comment

by:zlatev
ID: 9786735
roverm, there are also automated .NET translators
http://www.remotesoft.com/octopus/try.html
http://authors.aspalliance.com/aldotnet/examples/translate.aspx
http://www.kamalpatel.net/ConvertCSharp2VB.aspx

Hey it is all .NET under this fancy dress (call it C#, VB.NET whatever)
There are minor non-directly convertible commands between C# and VB.NET.

Kind Regards,
Zlatin
0
 
LVL 6

Expert Comment

by:zrh
ID: 9788669
For example, C# doesn't support default member initializers for functions. :(
0
 
LVL 8

Expert Comment

by:zlatev
ID: 9789019
Yes, but notice that all these features are not part of the CLI standard.
0
 
LVL 6

Author Comment

by:PsychoDazey
ID: 9790281
Thanks guys, I think I have what I need here!  I split points because I ended up using pieces from both of you.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question