|
LOL ... I asked same thing but for certificates... and googling for you solution I think I found mine. Anyways... if you wish to control permissions use following code (example is for directory):
<br />
private static void GiveAccessToFolder()<br />
{<br />
string path = @"d:\testFolder\";<br />
DirectorySecurity ds = Directory.GetAccessControl(path);<br />
<br />
ds.AddAccessRule(new FileSystemAccessRule("ARCHITECT\\testuser", <br />
FileSystemRights.FullControl, AccessControlType.Allow));<br />
<br />
Directory.SetAccessControl(path, ds);<br />
}<br />
You can find more examples over here.
Enjoy friend!
|
|
|
|
|
Hello,
tks for help.
I tried to use this code, but I got a exception at this command
DirectorySecurity ds = Directory.GetAccessControl(path);
with message "Attempted to perform an unauthorized operation"
Almost there..heheheeh
|
|
|
|
|
NTFS doesn't support password protected folders. What kind of "shared folder" is this?? A password protected .ZIP file?
|
|
|
|
|
I assume he means the folder is a network share, and he needs a username/password to access it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I was thinking the same thing, but I didn't want to assume. You know what happens when we assume around here!
|
|
|
|
|
Cmon... assume some solution to my certificate problem
|
|
|
|
|
I didn't answer because it's outside my relm of experience and I've run out of time to try to setup a test environment for this.
|
|
|
|
|
Well
I created a shared folder, and I created also a user in the same machine (aka Maq048)
the user that was created is xmlowner, then I've a Maq048\xmlowner user.
In the folder I set permission to Maq048\xmlowner (full control), and now I want access this folder across network and save a file.
But I don't know how to authenticate this user by C# application.
|
|
|
|
|
You are looking for something like this?
|
|
|
|
|
Yeah, something like this..
I created one user at pc01 and the same user at PC02
I impersonate my user at PC02 then I obtained to have access the protected folder in PC02
Tks 4all!!!!
[ ]
|
|
|
|
|
Hi All
I am planning to write a monitor for my server which has seperate TCP/IP connections to and from external servers. I am frequently receiving and sending messages to them. I am using sockets for connections but I would also like to monitor the status of each TCP/IP connection (both incoming and outgoing), whether the connection is still there or not. Because in some cases these external servers goes down or due to network problem they loose connection without informing my server.
According to my understanding and knowledge, sockets can create a connection but you can only know about status of the connection (whether it is success or exception), when you send some data on it. This idea works when I will be using the connections for non stop communication but my concern is about the time when we do not have much messages comming and we are not sure when will the next message come. one idea was, I periodically send test messages to outgoing connections to external servers but then how these external systems know that it is just a test message (as there is no protocol between us like this). And also what happen to the incomming connections. Because I cannot just start sending messages on these connections as there could be some message comming to my server.
Let me know with your suggestions and questions.
Thanks
Adeel Aslam
|
|
|
|
|
This is useless because the monitor can't do anything. Your monitor won't know there is a problem until it's too late. Your application will also have to interact with this monitor so it knows what it's looking for, no what it's no longer supposed to be looking for. If the server cuts out, your app, nor your monitor will never know about untilo your app tries to send. The only thing will happen is that your app and the monitor will just be waiting for a response that won't come.
The best way to handle this is better exception handling and recovery on your side. Even with the monitor, it's what you're going to be forced to do anyway.
|
|
|
|
|
Hello All!!!
I have JUST (like 2 days ago) started learning Visual C# 2005 and because of my history with C++, I am picking it up like ET on Smarties. I was messing around one day with Form.Opacity and thought, hmmm... wouldn't it be cool if you could not only fade a window in when the program loaded but fade it out as well when it quit!?! Well...I have tried the following:
Attempt 1:
Created two timers, one for fading the window in and another to fade it out. The <timer>.Interval for both was 1ms. This worked beautifully for the window fading in when the program started because you would still be able to use any controls on the form while it was fading it in. Fading out posed a problem. I did some snooping and wrote an override for OnClosing using the event properties of the form from [Design]. I then ran into a problem. I cannot delay the close event while the window fades out.
Attempt 2:
Created infinite for loops to be executed during the Constructor and OnClosing functions of the form. Came into another problem...on construction of the form you would be greeted with an hourglass icon while the form faded in. OnClosing resulted in the form being repainted as if it were not responding if you changed focus to another window...I chalk this up to Windows XP actually.
Questions:
Is there a way to intercept or redirect the Event created by that wonderfully close button in the top right corner of the window so that I may fade the window AND THEN process the close event? Would there be a way to implement this into a class library? and last but not least...I'm reading Beginning Visual C# 2005 by Wiley/Wrox (at the time I was writing this I was at chapter 10), can anyone offer any other titles that I can look into that will further my knowledge of this quite interesting language and all the .NET has to offer through it?
I thank you all for your time.
-=Wraith-Lunati=-
|
|
|
|
|
The EventArgs that is passed into the closing event has a flag you can set to reject the closing event, so your form won't close. You can do this, then set the timer to fade out, and have the timer when it ends, close the form. You'd need a flag you set so that the closing event doesn't get killed again the second time.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I like this idea...
Let me get this right though:
DummyClose function attached to FormClosing to be created.
DummyClose will cancel the OnClosing if window opaque and make it fade first.
FadeOut timer needs to call this.Close() which will check opaque and actually close.
BTW thank you for such a quick reply!!!
|
|
|
|
|
Well, it's not a dummy close, it's an event handler which cancels the close if the form is opaque and starts a timer which fades the form and then closes it again.
Welcome
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
How bout TrojanClose? lol.
|
|
|
|
|
OMG That is sooo cool!!! Now I will attempt to make this into an abstract class library I can use as a base for forms.
This is made from a Windows Application template...try it out!!!
If you copy and paste it won't work I hope most of you know that :P
WARNING: This code is just an example. I assume most of you know what to do or you wouldn't even try.
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace WindowsApplication1<br />
{<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
FadeIn.Enabled = true;
}<br />
<br />
private void FadeIn_Tick(object sender, EventArgs e)<br />
{<br />
Opacity += 0.005;<br />
if (Opacity > 0.995)<br />
FadeIn.Enabled = false;<br />
}<br />
<br />
private void FadeOut_Tick(object sender, EventArgs e)<br />
{<br />
Opacity -= 0.0025;<br />
if (Opacity < 0.0025)<br />
{<br />
FadeOut.Enabled = false;<br />
this.Close();<br />
}<br />
}<br />
<br />
private void DummyClose(object sender, FormClosingEventArgs e)<br />
{<br />
if (Opacity > 0)<br />
{<br />
FadeIn.Enabled = false;
FadeOut.Enabled = true;
e.Cancel = true;<br />
}<br />
}<br />
}<br />
}<br />
|
|
|
|
|
It sounds pretty cool, I reckon if you wrote up an article about a new base Form class which offered this, a lot of people would use it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I'm still pretty new to this site and I have never written an article before. Though I have read a few of them from here before and...well...some of them make me cringe sometimes the way they are laid out. Would you be willing to offer some of your obvious wisdom into helping me complete this task via e-mail? if so reply via said medium and we'll soon talk.
Thank you...
|
|
|
|
|
You need to confirm your email address before I can send you an email. I'd give you my email address publically, but who knows what email I'd get if I did that ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
hi all
I wanted a way to kill a spesific proccess for example winword.exe for a spesific user ( the user that runs the program)
there is more than one user logged on to the server so i cant have it kill all winword.exe's
any idea on how to do this?
|
|
|
|
|
You may have to P/Invoke OpenProcessToken (advapi32)[^]. Get the token information and check if the username and the process name are the one you want to kill. Get the handle and using a win32 method kill the application.
|
|
|
|
|
I was thinking more something like
For Each proc As Process In Process.GetProcessesByName("process name here") proc.CloseMainWindow() 'ask the process to exit.
proc.WaitForExit(10000) 'wait up to 10 seconds.
If Not proc.HasExited Then
proc.Kill() 'force the process to exit.
End If
Next proc
But this is in VB
|
|
|
|