file exists function on unc path with server name possible?

Dani_S 3,766 Reputation points
2024-08-21T08:19:58.9566667+00:00

Hi,

I'm in net 8, if i have unc path = \servername\domain\myfolde \myfile.xml

Can i used function File.Exists(uncPath)?

Thanks,

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,833 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,469 questions
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 64,826 Reputation points
    2024-08-27T15:47:59.64+00:00

    first unc paths are only supported when .net 8 is hosted on windows. second, I don't know what you mean by domain. the unc path syntax is:

    \\<servername>\<share name>\<optional path>\<filename>

    the sever must define the share, and the calling thread must have read access to the share and file folder or a file not found error is returned.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 31,161 Reputation points Microsoft Vendor
    2024-08-27T05:48:25.92+00:00

    Hello,

    You cannot use File.Exists in your App to determine if the file exists on the server side. This method can check if the file exists in local.

    You can check whether the file exists on the server side, and then send an HTTP(s) request on the client side (your app) to communicate with server side and then check whether the file exists.

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.