|
Hello Everybody,
If my application is running in administrator Previledge (Run as admin) then i am executing any application from this
application.The Executed application is also run with Administrator Mode. But i want to run it with current user Previledge.
pls describe me how can it possible.
Thanks
If you can think then I Can.
|
|
|
|
|
eg_Anubhava wrote: But i want to run it with current user Previledge.
Only the user can run processes under his privileges, if you're an admin you'll spawn processes with admin-privileges. You can use the Proces class to spawn a process under a different account, but you'll need the users' name and password. Point is that your process isn't in the users' space, and it has to provide the right credentials before it's allowed there
I are Troll
|
|
|
|
|
I have decided that I need a better way of validating data.
I currently have various objects that can validate information, for example:
if(TextBoxValidator.IsValidTextBox(tbText))...
Also I tend to use the Debug.Assert() methods often, making sure that null or invalid states of variables are shown.
Its starting to get repetitive when I validate:
if(fileDetails.ToString() == string.Empty || map == null) return Common.ReturnResult.Failed;
if(map.StaticImages == null || map.Tiles == null) return Common.ReturnResult.Failed;
if(map.Infomation.Columns == 0 || map.Infomation.RootContentFolder == string.Empty || map.Infomation.Rows == 0 || map.Infomation.TileSize == 0)
return Common.ReturnResult.Failed;
There must be a better way to validate methods input and such than this!
Any suggestions, Thanks 
|
|
|
|
|
One way is to avoid nulls in the first place, but if you need to check , here is a start, it is longer but clearer to read:
...
bool Success(footype map)
{
if(map.StaticImages == null)
return false;
if(map.Tiles == null)
return false;
if(map.Information.RootContentFolder == "")
return false;
if(map.Infomation.Rows == 0)
return false;
if(map.Infomation.TileSize == 0)
return false;
}
public Foo()
{
if(fileDetails.ToString() == string.Empty)
return Common.ReturnResult.Failed;
if(map == null)
return Common.ReturnResult.Failed;
if(!Success(map))
return Common.ReturnResult.Failed;
return Common.ReturnResult.OKorWhatever;
}
Can you change the map object? If so the Success Status is probably better off there as a property, you could also break this down into further sub-properties such as HasImages , HasInformation etc
|
|
|
|
|
May be better to use CASE statement.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
What about an "IValidable " interface defining a method "Validate() "?
When "map" and its properties implement it, you could simply call map.Validate() which would encapsulate that logic there.
|
|
|
|
|
Thanks for the reply,the problem is that I would have allot of validation objects everywhere, which wouldn't be very fun to use...
|
|
|
|
|
HOw about
public bool CheckForNulls(object[] thingsThatShouldntBeNull)
{
return thingsThatShouldntBeNull.TrueForAll(x => x != null);
}
CheckForNulls(new object[]{dumbshitCoderField1,dumbShitCoderField2);
|
|
|
|
|
Anyone know why isn't this working?
The line oSheet.Cells[row, column] = data; works correctly and it writes to incrementing columns and rows correctly, but I would like it to see if data contains a \\ and then make it a hyperlink if it does.
Thanks for reading.
oSheet.Cells[row, column] = data;
if ((data.Contains(@"\\")) && (createSheet == false))
{
oSheet.Hyperlinks.Add(oSheet.get_Range(row, column), data, System.Type.Missing, System.Type.Missing, data);
}
|
|
|
|
|
The main problem is the way you are adding the hyperlink.
Instead of Hyperlinks.add you could try Range.ApplyFormula .
Obviously you have to define the formula...
string filexl = @" C:\NewFile.xls";
Workbook wbnew = new Workbook();
Worksheet wsnew = wbnew.Worksheets.Add("New");
wsnew.Rows[0].Cells[0].ApplyFormula(@"=HYPERLINK(""http://www.codeproject.com"",""Urgentzzzz"")");
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
Thanks, I will try this tomorrow
|
|
|
|
|
Hi Dalek,
As an update, I tried this, it does not work in my IDE. I have 2008 express .net 3.5.
I do not have an option for .ApplyFormula and my oSheet.Cells or oSheet.Rows have to be defined with [row, column].As an update,
|
|
|
|
|
URLs tend to contain forward slashes, not backslashes.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Do you know I looked at that and still didn't see it!
That gets an upvote for Olympic Standard Noticing
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
Maybe you need polarizing spectacles?
Always see what is there and don't see what isn't.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi Luc!
You are right, this is actually a UNC path
I believe it is still considered a hyperlink, but I may have used the wrong terminology, I used hyperlinks because of the c# method terminology.
|
|
|
|
|
Here is what works, thanks to all that contributed and answered
oSheet.Cells[row, column] = data;
string cell = oSheet.Cells[row, column].ToString();
if ((data.Contains(@"\\")) && (createSheet == false))
{
Excel.Range rng = (Excel.Range)oSheet.Cells[row, column];
oSheet.Hyperlinks.Add(rng, string.Empty, data, "", data);
}
|
|
|
|
|
Hi,
I'm new in DB programming in .net context and I have a question.
If I use a DB in my internet site (es www.mysite.org), I can quering this DB from my desktop application using ADO.net?
Thank a lot.
Alex
|
|
|
|
|
Yes, as long as the database server can be connected to remotely. If it can't be done that way, you can always create a web service to handle the access, and just connect to the web service instead.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
My 5! Good answer since it's most likely that the webserver is behind a firewall. A webservice is a good and viable solution.
|
|
|
|
|
If it's hosted then the database will be likely hiding behind a firewall. Yup, webservices are the way to go
I are Troll
|
|
|
|
|
I second (third?) a Web Service. But I question the need to query from the client side. You'll have to be very wary of SQL injection, but you can probably minimize the risks.
|
|
|
|
|
I want to add directory security to certain folders on my system,
the code is
NTAccount identity = new NTAccount(Account);
SecurityIdentifier sid = (SecurityIdentifier)identity.Translate(typeof(SecurityIdentifier));
DirectoryInfo dInfo = new DirectoryInfo(Dir);
DirectorySecurity dSecurity = dInfo.GetAccessControl(AccessControlSections.Access);
dSecurity.AddAccessRule(new FileSystemAccessRule(sid , Rights, ControlType));
dInfo.SetAccessControl(dSecurity);
but i keep getting this error:
some or all identity references could not be translated
|
|
|
|
|
Why doesnt it download every files in this code?
All files that have been downloaded is shown in the listview, but when i open the folder where the files are, then some of files has not been downloaded.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnDownload_Click(object sender, EventArgs e)
{
string p1 = @"\";
string p2 = TBSaveTo.Text;
string p3 = TBSaveAs.Text;
listView1.Items.Clear();
label1.Visible = false;
HttpWebRequest request = null;
HttpWebResponse response = null;
WebClient wc = new WebClient();
string ret = "";
for (int i = 2000; i < 2312; i++)
{
string sFiles = string.Format("http://www.svenskaspel.se/includes/xmlelements/XMLresultat.asp?produktid=30&omgang={0}", +i);
listView1.Items.Add(new ListViewItem(p2 + p1 + "omgang=" + i + p3));
{
try
{
request = (HttpWebRequest)WebRequest.Create(sFiles.Trim());
request.Method = "GET";
request.ContentType = "application/x-www-form-urlencoded";
request.Timeout = 15000;
response = (HttpWebResponse)request.GetResponse();
ret = new StreamReader(response.GetResponseStream(),
Encoding.Default).ReadToEnd();
wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
wc.DownloadFileAsync(new Uri(sFiles.Trim()), String.Format(p2 + p1 + "omgang=" + i + p3, Path.GetExtension(sFiles)));
wc.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wc_DownloadFileCompleted);
response.Close();
}
catch { }
finally
{
if (response != null)
{
response.Close();
}
}
}
}
}
private void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
this.label1.Visible = false;
}
private void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
this.label1.Visible = true;
}
private void btnBrowse_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
TBSaveTo.Text = folderBrowserDialog1.SelectedPath;
}
}
}
}
/Kenneth
|
|
|
|
|
Member 2168103 wrote: catch { }
that is just stupid.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|