|
|
Hello, I am new in this forum and this time I need your friendly help:
my problem is, that this exception appears when "pathName" is an UNC path name.
public Boolean CheckPathName(string pathName,
FileSystemRights rights,
AccessControlType type)
{
Boolean ok = false;
try
{
_accountName = System.Environment.UserDomainName +
'\\' + System.Environment.UserName;
if (Directory.Exists(pathName))
{
AddDirectorySecurity(pathName, _accountName, rights, type);
ok = true;
}
}
catch (InvalidOperationException ex)
{
throw ex;
}
return ok;
}
public static void AddDirectorySecurity(string FileName, string Account, FileSystemRights Rights, AccessControlType ControlType)
{
DirectoryInfo dInfo = new DirectoryInfo(FileName);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(new FileSystemAccessRule(Account, Rights, ControlType));
dInfo.SetAccessControl(dSecurity);
}
can someone help me?
|
|
|
|
|
Don't use throw ex; - it destroys the stack trace, and makes it harder to diagnose the problem.
Either use throw; to rethrow the exception, or remove the try...catch block altogether.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Richard,
thank you for your reply.
I changed the code, but result is the same.
try
{
_accountName = System.Environment.UserDomainName +
'\\' + System.Environment.UserName;
if (Directory.Exists(pathName))
{
AddDirectorySecurity(pathName, _accountName, rights, type);
ok = true;
}
}
catch (InvalidOperationException ex)
{
throw;
}
|
|
|
|
|
I am developing an window form application, in which i am playing an audio of wave format, and want to convert that pre recorded speech or audio into text format(using speech api) and display that text in the label.
I started a thread for audio to text conversion in the play button, now i want to pause that thread on the pause button(means how to pause a that thread). I used ManualEventReset method. but in the pause button when i am using signal.waitone() methods. this freez the whole form. please help.some parts of my code is given here.
//pause button
ManualResetEvent signal = new ManualResetEvent(false);
ManualResetEvent signal = new ManualResetEvent(false);
private void buttonX15_Click(object sender, EventArgs e)
{
method_pause();
}
public void method_pause()
{
clip.Pause();
visular1.Stop();
visular2.Stop();
visular3.Stop();
visular4.Stop();
visular5.Stop();
this.pause.Hide();
signal.WaitOne();
play.Show();
}
private void play_Click(object sender, EventArgs e)
{
playsub();
labelX1.Text = "Play";
}
public void playsub()
{
starter = delegate { subt(FName); };
thread=new Thread(starter);
try
{
thread.Start();
method_play();
}
catch(Exception ex){}
}
from where i can set the thread.
|
|
|
|
|
You haven't posted all your code and it looks, to me, that you are starting the video through your method_play method, which is happening on the primary thread.
|
|
|
|
|
picture 1
picture 2
I made method for checking if all pieces are in base or goal if yes it returns true,now i need another method.
If pieces are ordered like on Picture 1. i need to change number of throws to 3 ,if pieces are ordered like on Picture 2 i can allow only 1 throw cos of empty space between.
I got 4 goalPositions and 4 piecePositions,and need to check if pieces are ordered on them from 54-51 path positions(path is array of 55 fields 0-54) ,if yes return true if not return false.
I am new to C# never had chance to work with order checking till now.
I was trying to do it with 3 int lists goalPositions (populated with 51,52,53,54 path positions),piecePositions(populated with pieces positions with getPosition()),and piecesOnGoal. but no luck with that.
ill add some code. part of player class with that lists and method for checking pieces in goal or base
class Player
{
protected PieceSet[] pieces;
Color color;
int numberOfThrows;
Dice dice;
public List<int> goalPositions;
public List<int> piecePositions;
public List<int> piecesOnGoal;
public enum Color
{
Yellow, Green, Blue, Red
}
public Player(Color color)
{
int[] path = new int[55];
this.color = color;
dice = new Dice();
numberOfThrows = 3;
switch (color)
{
case Color.Yellow:
path = BoardHelper.getYellowPath();
break;
case Color.Green:
path = BoardHelper.getGreenPath();
break;
case Color.Blue:
path = BoardHelper.getBluePath();
break;
case Color.Red:
path = BoardHelper.getRedPath();
break;
}
pieces = new PieceSet[4];
pieces[0] = new PieceSet(path, 0);
pieces[1] = new PieceSet(path, 1);
pieces[2] = new PieceSet(path, 2);
pieces[3] = new PieceSet(path, 3);
piecePositions = new List<int>(4);
piecePositions.Add(pieces[0].getPosition());
piecePositions.Add(pieces[1].getPosition());
piecePositions.Add(pieces[2].getPosition());
piecePositions.Add(pieces[3].getPosition());
goalPositions = new List<int>(4);
goalPositions.Add(51);
goalPositions.Add(52);
goalPositions.Add(53);
goalPositions.Add(54);
piecesOnGoal= new list<int>();
}
public bool isAllPiecesInBaseOrGoal()
{
if ((pieces[0].getPosition() < 4 || pieces[0].getPosition() > 50) &&
(pieces[1].getPosition() < 4 || pieces[1].getPosition() > 50) &&
(pieces[2].getPosition() < 4 || pieces[2].getPosition() > 50) &&
(pieces[3].getPosition() < 4 || pieces[3].getPosition() > 50))
return true;
else
return false;
}
and this is how i was thinking to solve my problem ,check if goalPositions contains piecePositions if yes add that position into piecesOnGoal ...now i need somehow to check are that piecesOnGoal are ordered if yes return true if not false.
I am open for any suggestion.
public bool isAllPiecesAreOrderedInGoal()
{
for (int i = 0; i < 4; i++)
{
if (goalPositions.Contains(piecePositions[i]))
{
piecesOnGoal.Add(piecePositions[i]);
}
}
}
Any help is appreciated.
Its kind of urgent.
Thank you in advance.
|
|
|
|
|
Aleksandar Jeftic wrote: Its kind of urgent.
Not to us.
|
|
|
|
|
thx for your useless comment
|
|
|
|
|
I would do the check in stages. For the piecesOnGoal you only need the count, not the individual numbers. So start like this:
int piecesOnGoal = 0, piecesOnBase = 0;
for (int i = 0; i < 4; i++)
{
if (piecePositions[i] > 50)
piecesOnGoal++;
else if (piecePositions[i] < 4)
piecesOnBase++;
}
for (int i = 0; i < piecesOnGoal; i++)
{
}
return true;
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
Ive been researched about ICS in C# for Windows 7/8+, but there's no source codes i've found yet. Ive been planning to make a Hotspot Management networking tool via C# and would like to share here. Therefore, I dont want to use packet capture method like WinPCap or SharpPcap cause its kinda complicated.
So far I've found for Windows OS is ICS can be related with Hotspot.
However, for Linux is: FreeRadius & CoovaChilli.
There's closed-source such as CuteHotSpot, MyHotSpot, y2cloud hotspot Management.
The open-source is : EasyHotSpot, but only works with Linux because its requires FreeRadius and CoovaChilli.
This is how the hotspot works:
Internet Gateway (192.168.1.1, 255.255.255.0)
|
|
|
| NIC 1: 192.168.1.2, 255.255.255.0
Server X (OS: Windows 7, ICS enabled)
| (Apache + MySQL Servers: csharp-hotspot.com)
| (planned for HotSpot management server in C#)
| NIC 2: 192.168.137.1, 255.255.255.0
|
|
|
Access Point (192.168.2.1, Gateway: 192.168.137.1)
| (DHCP: 192.168.2.50-254)
|
-------------
| |
| |
| |
PC 1 PC 2
(192.168.2.50) (192.168.2.51)
I just need know how to do this with ICS and is it possible in C# language? The C# hotspot management system i wanting to made will be running in the "Server X", along with Apache and MySQL Server as well.
How Hotspot Management System works?
1) When PC 1/2 open any websites (ie: codeproject.com)
2) The server send response to PC 1/2: (ie: csharp-hotpot.com)
3) PC 1/2 login at csharp-hotspot.com
4) The server send response: login success
5) Pc 1/2 will be redirected to the website they have entered (ie: codeproject.com)
Similar with?
- StarBuck Wifi Hotspot
- Any Cafe Wifi Hotspot
Thanks...
Im noob. haha
|
|
|
|
|
I have a image and i want that to be inserted in excel programmatically using c#. So i have written the below code.
string logoLocation = Server.MapPath("/images/logo.bmp");
WorkSheet.Shapes.AddPicture(logoLocation, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoCTrue, 1, 1, 200, 62);
But the problem is its getting inserted as it is
I want that to be inserted with the lines as transparent
But as per my understanding this can be achieved non programmatically with below steps
1. Select the image to modify.
2. Make sure the Format tab of the ribbon is displayed.
3. In the Adjust group click the Recolor tool or the Color tool (depending on your version of Excel). ...
4. Click Set Transparent Color.
I am unaware of doing the same using c# coding . Please help me in achieving this
|
|
|
|
|
The AddPicture[^] method returns a Shape[^] object.
The Shape object has a PictureFormat[^] property which returns a PictureFormat[^] object.
The PictureFormat object has a property called TransparentBackground[^], and another called TransparencyColor[^]. Set TransparentBackground to true , and TransparencyColor to the RGB value of the colour you want to make transparent.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
My code:
private void load()
{
IsSensorListVisible = Properties.Settings.Default.SensorListVisible;
IsSensorListOpen = Properties.Settings.Default.SensorListOpen;
IsSensorListExpanded = Properties.Settings.Default.SensorListExpanded;
CameraView = Properties.Settings.Default.CameraView;
}
private void save()
{
Properties.Settings.Default.SensorListVisible = IsSensorListVisible;
Properties.Settings.Default.SensorListOpen = IsSensorListOpen;
Properties.Settings.Default.SensorListExpanded = IsSensorListExpanded;
Properties.Settings.Default.CameraView = CameraView;
Properties.Settings.Default.Save();
Properties.Settings.Default.Reload();
}
The SAVE doesn't save changes. Ever time I run I get the default values.
What's wrong here?
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: The SAVE doesn't save changes. Ever time I run I get the default values. Is there a file created under C:\users\you\local\?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes, bubt the values are not saved
If it's not broken, fix it until it is
|
|
|
|
|
Can you open the file and verify that it contains the default values?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I was wrong. The value ARE saved, just not retrieved on the next run.
If it's not broken, fix it until it is
|
|
|
|
|
Is this when you run your application from inside Visual Studio? If so, check the properties on the file containing your settings - I bet they are set to copy over every time, which means you are overwriting them when you run the application.
|
|
|
|
|
If you're referring to App.Config, it's set to Do Not Copy
If it's not broken, fix it until it is
|
|
|
|
|
That setting doesn't really apply to App.Config. If the file already exists in the bin\Debug or bin\Release folder, it won't be overwritten with a new copy. But, there are cases where it will be rewritten. For example, doing a Rebuild of your project/solution will overwrite the app.config with a clean copy.
|
|
|
|
|
Ok, so I still don't know why my settings are not being retrieved
If it's not broken, fix it until it is
|
|
|
|
|
I think you must call Properties.Settings.Default.Reload() at the beginning of your load method, not at the end of save method
|
|
|
|
|
Calling reload likely reloads the default settings from the app.config file. Don't call it and that might fix your issue.
Just a shot in the dark here as I don't use the built-in settings system. I use a system based on SharpDevelop's PropertyService.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
hello
is there any c# code
can change internet ip?
|
|
|
|