Directory.CreateDirectory not working.

qianhong li 0 Reputation points

I want make a program to transfer files from iPhone to my pc.

I use Directory.CreateDirectory to create the directory.

But for the directory name end with "__", Directory.CreateDirectory not working.

No exception raised!, and the directory not created!

I have do some test.

Directory.CreateDirectory("E:\photos\202305\202305_"); => worked.

Directory.CreateDirectory("E:\photos\202305\202305__"); =>not worked!

Directory.CreateDirectory("E:\photos\202305\202305___"); => worked.

Directory.CreateDirectory("E:\photos\202305\202305__a"); => worked.

Why the Directory.CreateDirectory can not work for the directory end with double underscore ?

System info:

Windows 11 Home 22000.1817

Framework .Net 6.0

Visual Studio 2022 Community

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,461 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,591 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,036 Reputation points

    Hello there,

    Could you check the Capabilities in your package.appxmanifest to see if there is <rescap:Capability Name="runFullTrust" /> under it ? When you package your WPF as a desktop bridge app, this capability need be added under the Capabilities . runFullTrust is a capabilities which allows apps to run at the full trust permission level on the user's machine.

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments