create uri to file in current working directory

I’m trying to write a c# program using EPPlus ( that generates an Excel worksheet with thumbnails of images and links to the full-sized image.  The images reside in the same folder as the executable and the resulting spreadsheet. It is all working OK with the following:
int a = 1;
Image fullSize = Image.FromFile(@"Screenshot.jpg");
Image.GetThumbnailImageAbort myCallback = new
Image thumb = fullSize.GetThumbnailImage(100, 71, myCallback, IntPtr.Zero);

var picture = worksheet.Drawings.AddPicture(a.ToString(), thumb);
picture.SetPosition(a-1 , 0, 6-1, 0);

worksheet.Cells[a, 6].Hyperlink = new Uri("file://c:/Screenshot.jpg");

Open in new window

What I want to do is make the whole thing location independent. As it is, the paths to the full-size jpgs are hard-coded. I would like them to be located wherever the current working folder is.

I have tried all sorts of things, and so far have been unable to get the .net Uri format to agree with Excel.

I did some digging and generated a sample spreadsheet in Excel and added a uri to a cell pointing to a jpg in the current folder. I then opened the .xls file with 7-zip (who knew you could do this?) and saw this snippet in sheet1.xml:
<hyperlinks><hyperlink ref="F2" r:id="rId1"/></hyperlinks>

Open in new window

In sheet1.xml.rels, I found this:
<Relationship Id="rId1" Type="" Target="Screenshot3.jpg" TargetMode="External"/>

Open in new window

Moving the xls file to the desktop and opening it with Excel and clicking the hyperlink produces a “cannot open the specified file” error. Moving the jpg file to the desktop and then clicking the hyperlink works fine.

So, it appears that Excel’s file format allows for hyperlinks to a relative uri. The question is, how do I generate such a uri and hyperlink programmatically?

I'm stuck at something that really ought to be easy. The hacker in me says I should just script up something that disassembles the .xlsx file (I had no idea until today that you could do that with 7-zip), make the necessary changes and then zip it back up. But that's absolutely nuts, I think.

There's GOT to be a better way,
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.

1_21gigawattsAuthor Commented:
causes this error:
  Invalid URI: A Dos path must be rooted, for example, 'c:\'.


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
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

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.