Solved

Refresh Link in Internet Explorer

Posted on 2003-11-18
17
844 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
  • 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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now