Refresh Link in Internet Explorer

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?
LVL 6
PsychoDazeyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mondayblueboyCommented:
0
DranizzCommented:
<META HTTP-EQUIV=Refresh CONTENT="20; URL=http://www.bob.com/">
0
zrhCommented:
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
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

PsychoDazeyAuthor Commented:
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
zrhCommented:
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
rovermCommented:
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
PsychoDazeyAuthor Commented:
let me look into the front page extensions, I hadn't thought about that.
I'll get back to you.
Thanks all
0
zrhCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rovermCommented:
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
rovermCommented:
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
zrhCommented:
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
rovermCommented:
ZRH: Can I contact you if I want some code translated from VB to C#?? ;-)
0
zrhCommented:
Roverm: Sure :)
0
Zlatin ZlatevTechnical ArchitectCommented:
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
zrhCommented:
For example, C# doesn't support default member initializers for functions. :(
0
Zlatin ZlatevTechnical ArchitectCommented:
Yes, but notice that all these features are not part of the CLI standard.
0
PsychoDazeyAuthor Commented:
Thanks guys, I think I have what I need here!  I split points because I ended up using pieces from both of you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.