Click here to Skip to main content
15,850,921 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All

I have a C#/Selenium automation test which while running needs to read the contents of xlxs file.

What I have tried:

The link to the file is ->
href = "blob:"

And when I try this
using var stream = File.OpenRead(@href);

I get the following error
System.IO.IOException: 'The filename, directory name, or volume label syntax is incorrect. : 'C:\KevsTest\Debug\net6.0\blob:https:\\c7a70bf0-7495-48f8-b989-be0035eb79fd''

for some reason
is being pre-pended to the link. Can anyone assist with this please?
Updated 20-Jun-23 9:20am
Richard MacCutchan 20-Jun-23 11:26am    
Most likely because the href is being read as a relative path, so it prpends the current working directory. However the actual reference you show does not look like a path to an Excel file.

1 solution

You're getting the error because it think's you're specifying an invalid drive letter. Look at the path you told it to open:

There can only ever be a single colon in the path, with a single character before it, specifying the drive letter. You have two colons.

The next problem is you cannot use the File class to open a "file" returned by a URL. You have to use the WebClient class to download the file, then you can open the local copy of the file.
WebClient.DownloadFile Method (System.Net) | Microsoft Learn[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900