jetbet
asked on
C# Get image from Network Drive
I am trying to load an image located on a shared folder, on a mapped drive, into a picture box.
File.Exists always returns false even when the file exists.
Can anyone tell me why? I have given everyone Full access to the share.
File.Exists always returns false even when the file exists.
Can anyone tell me why? I have given everyone Full access to the share.
private void AssignRunnersToPictureBoxes(EventDetails race)
{
String filePath = "I:\\";
if (race != null)
{
for (int i = 1; i < 25; i++)
{
PictureBox box = GetPictureBox(i);
if (box != null)
{
RunnerDetail runner = race.runners.GetRunner(i);
if (runner == null)
{
box.Tag = null;
box.Hide();
}
else
{
box.Tag = runner;
// box.BackColor = Color.Green;
// String silksFile = Path.Combine(filePath, "USA_Raci_3FBA615C103B385F0A7732B2D71BD1C8.png.bmp");
String silksFile = Path.Combine(filePath, runner.silkFileName + ".bmp");
if (File.Exists(@Path.Combine(filePath, runner.silkFileName + ".bmp")))
{
box.Image = Image.FromFile(silksFile);
}
box.Show();
}
}
}
}
}
ASKER
The file is a converted png that has the .bmp added so it is blahblahblah.png.bmp
The name stored in the object (runner) does not have this extra extention added on.
SilksFile is a local String variable silkFileName is a property on the object.
I am unsure of the solution you are proposing
The name stored in the object (runner) does not have this extra extention added on.
SilksFile is a local String variable silkFileName is a property on the object.
I am unsure of the solution you are proposing
Print debug the full path after it has been combined.
String silksFile = Path.Combine(filePath, runner.silkFileName + ".bmp");
What does silksFile look like?
String silksFile = Path.Combine(filePath, runner.silkFileName + ".bmp");
What does silksFile look like?
ASKER
The path is correct. I have checked this carefully in the debugger.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the detailed response.
I will check out your ideas as soon as I can but am in the middle of a different project at the moment.
I will check out your ideas as soon as I can but am in the middle of a different project at the moment.
if (File.Exists(@Path.Combine
you seem to have a preoccupation with adding + ".bmp" everywhere!
String silksFile = Path.Combine(filePath, "USA_Raci_3FBA615C103B385F
// inconsistent filename string name -- silksfile AND silkFileName