[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Refresh Link in Internet Explorer

Posted on 2003-11-18
17
Medium Priority
?
852 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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 1000 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 1000 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:Zlatin 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:Zlatin 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

650 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