You really should look up the various classes and methods you are using on MSDN. Directory.GetFiles with one string parameter will return an string array containing the path of all files in the directory specified in the parameter. If you want to specify a search pattern, you need to pass two string parameters, the first being the path to the directory, the second being the pattern.
The result will be a string array. You can foreach over that and pass each string into a FileInfo constructor if you wish.
I am trying to create a file on a directory where I have total power.
The File.Create (..) (as well as any other attempt to create the file even using FileStream()) always fails with the UnauthorizedException .
This is not possible since I have permission to write and create files on that directory (after all I can easily create a file by hand there).
I am running a debug instance of my program.
VS runs under my credentials.
The path is simply the debug folder of the application.
This is the same path where I was successfully reading and writing, yesterday, using the same VS, and NO change has been made since .
Something has changed for sure . But if I were the one who changed that something I wouldn't be here to pose this question.
I am not running anything which may lock the file. After all the file cannot even be created.
Running the environment as administrator even worsened things, as now the path of the file changed to something "like" root ("C:.\filename", which doen not even elaborate to a regular path).
as now the path of the file changed to something "like" root ("C:.\filename", which doen not even elaborate to a regular path).
I would suggest you have a bug in your code which is leading to an invalid path somewhere. Use your debugger to step throught the code and see the exact values of the variables that are used to create the path.
One of these days I'm going to think of a really clever signature.
You would also have to explain "what" the problem might be. If the problem is as broad as "I don't understand them", then the answer will be equally broad. For a general introduction to the topic, see MSDN[^].
In order to use true pointers, you need to execute what is called unsafe code
This means you have to do two things:
1) Turn on unsafe code in your app (it is off by default). This is on the Build tab of your project properties.
2) Put the pointer use into an unsafe block. There is an example on the MSDN page: http://msdn.microsoft.com/en-us/library/chfa2zb8(v=vs.71).aspx[^]
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
As others have said, you can use unsafe code. Alternatively, you can often use SafeHandles, GCHandles, GC.AllocHGlobal / GCFreeHGlobal along with IntPtr etc instead to achieve most things without needing to go quite as far as unsafe.
Without knowing the specifics then it is impossible to advise what is the best solution.
I doubt that your real need it to use pointers. Your need is to solve a problem that requires you to use pointers in languages like C and Pascal. That doesn't mean you need to use pointers in other languages.
In C#, every object is implicitly referenced through a "pointer" (which isn't a memory address, but an object reference). Say, to build a directed tree in a brother/son fashion, you declare your "myObject" class defines members "brother" and "son", both of class "myObj". Their values are not stored in the current node; the current node refers to ("has pointers to") the brother and son. There is no syntactical indication of this, because it is always so for class members.
Atomic members such as int and bool do reside in the class object, object members never do. You must be aware of this distinction - e.g. if you use the int member "age" as a method argument (without modifiers), a copy is provided to the method, but if you use "brother" as an argument, a reference ("pointer") is provided, not an object copy.
If you do not want to sent a copy of a single int, but a reference, you can use the Int class, which behaves just like your myObject instances: A reference is passed, not a copy of the value. But note that you don't need to use Int objects for allowing a method to change a parameter; you can add the modifier "ref" (or "out") to it, but you must add "ref"/"out" both in the formal declaration of the method and everywhere it is invoked.
The only time you need to handle pointers in C# is when interacting with unmanaged code, e.g. for a number of Windows system calls that are not directly available in C#. But you should avoid "using" pointers as much as possible: Treat them as opaque handles. Above all: Stay completely away from doing arithmetics on pointers! (Those who know what can and can't be done in that area need not ask questions about pointers in C#... )