|
Yeah, you never supplied the values for any of the parameters. Keep reading those links. You might want to pick out stuff that mentions "OldDbParameter".
|
|
|
|
|
what did you mean ? these commands must become
string OldPassword = txtOldPassword.Text;
string Username = txtUsername.Text;
string Password = txtNewPassword.Text;
like this:
command.Parameters.AddWithValue(@"OldPassword", txtOldPassword);
command.Parameters.AddWithValue(@"NewPassword", txtNewPassword);
command.Parameters.AddWithValue(@"Username", txtUsername);
????
sorry but i don't understand what you mean with Keep reading those links. You might want to pick out stuff that mentions "OldDbParameter".
modified 12-Mar-13 15:00pm.
|
|
|
|
|
Hi,
I am using WMI to make a call to an executeable on a remote server.
I have this defined in the managementpath, \\\\<servername>\\root\\cimv2:Win32_Process
My actual exe is located on the D drive of the same machine.
Is it required that this exe also be located on the C drive of the remote server????
Also, in the ManagementBaseObject class, method the InvokeMethod as a returnValue parameter. What are all the possible values for this parameter?
What value is returned if successful versus failed?
Thanks so much!!
modified 11-Mar-13 15:27pm.
|
|
|
|
|
Try reading the documentation on the Win32_Process class, Create method.Create method[^] for the return values.
If you're trying to run a process remotely that puts up a user interface, like Notepad for example, for the logged in user to see, you can't. It's a HUGE security risk, so WMI won't let you do it.
You CAN however run an executable that does NOT show any user interface, like a Console application.
You can launch the .EXE with the file being on your machine but ONLY if the .EXE file resides in a network share ono your machine. If you don't understand Windows Networking, just copy the .EXE file to the target machine and launch it from there. It's much simpler to do.
|
|
|
|
|
Awesome!! thanks, that is what I was looking for, in terms of what is returned in the returnValue parameter.
It is a console based application, which does NOT put up a user interface.
This works well!
|
|
|
|
|
How can I integrate open office impress in my C# windows form application.
I want to load a .ppt, .odp file and show it on my form using C#.
It's a presentation control app.
Any suggestion?
Thanks!
|
|
|
|
|
|
I'm using this SDK already.
but all the search tends to only format conversion or spreadsheet examples.
Not getting any way how to use Impress or presentation.
Do you have any idea?
Thanks!
|
|
|
|
|
|
Install the PowerPoint viewer[^] (it's free) and automate it. Don't bump your question.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have a text file containing the following content:
0 12
1 15
2 6
3 4
4 3
5 6
6 12
7 8
8 8
9 9
10 13
the first column specifies the x coordinate of a point and second column specifies the y coordinate.i need to read this file and find slope between all points. like first i find slope between (0,12) and (1,15) and then between (0,15) and (2,6) and so on.i am basically building a wpf application.can anyone help?
|
|
|
|
|
The basic forumula for a slope is (y2 - y1) / (x2 - x1 ).
Since you have all the co-ordinates, you can put them into an array and then run a loop over the array.
You can also input them via a textbox on WPF.
|
|
|
|
|
i tried to put x and y coordinates in two different arrays but don't understand how to write a code that calculates the slope between points and displays them in a textbox.
i have written the following code snippet:
var r = File.ReadAllLines(path)
.Select(line => line.Split(' '))
.Select(arr => new
{
Column0 = Int32.Parse(arr[0]),
Column1 = Int32.Parse(arr[1])
})
.ToArray();
int[] column0 = r.Select(x => x.Column0).ToArray();
int[] column1 = r.Select(x => x.Column1).ToArray();
|
|
|
|
|
Try
for (int i=0; i<=column1.Count - 2;i++)
{
float slope = (column1[i+1] - column1[i])/(column0[i+1] - column0[i])
}
|
|
|
|
|
Shouldn't you cast at least one of the operands of the division to float then?
|
|
|
|
|
i'm getting 'divide by zero' exception here.what is the method to fix this error?
|
|
|
|
|
If (x2 - x1) is 0, the slope is infinity.
Handle this case in code. Check and make sure (x2 - x1) is not 0 by a simple validation condition.
|
|
|
|
|
I want to create a presentation controller or a power point viewer using C#.
I have completed this using microsoft office 2007, but I want to make it not compatible with
microsoft office(because it's licensed).
If there is no MS-office is installed, program should work. And there shouldn't be any licensed
compatibility with the app. And my budget is low to purchase a library.
Do you have any idea?
Please share your opinions.
Thanks!
modified 11-Mar-13 1:58am.
|
|
|
|
|
If it is just .pptx that you need then you can write your own - all the information required is in ISO 29500 which can be downloaded freely.
If your time is free then no problem, but if you are being paid for your time (this is going to be a lengthy project) buying a library may be more cost effective.
For .ppt files I'm not sure. I have previously used NPOI for .xls, it may do .ppt too, you would need to have a look.
|
|
|
|
|
Thanks for your reply!
NPOI doesn't control .ppt yet.
http://npoi.codeplex.com/discussions/405690[^]
it's for .xls only.
I just want to open a .ppt file in my form and show it only.
Do you have nay suggestion ?
Thanks!
modified 11-Mar-13 3:32am.
|
|
|
|
|
Sorry, no other ideas. A commercial library or learning the office powerpoint binary format (probably not worthwhile as it's pretty much been replaced by the open and easier for coding pptx format) and rolling your own may be all that's left.
|
|
|
|
|
I have a question about how to modify the C# 2008 desktop foreach (String RFile in RFiles) block of code and/or the code that is surrounding this block of code. The code I am referring
to is listed below. Originally the code was setup to select files in a specific file directory. Now the requirements have changed where I need to loop through 4 subfoler directories that are at the same folder level. The 4 folder levels will be: 1. C:\customer\Mon_year\Cancel, 2. C:\customer\Mon_year\ED, 3. C:\customer\Mon_year\UI, and 4. C:\customer\Mon_year\UI.
Right now these are the only folders that will be setup at this level in the directory structure. However I can see how there can potentially be other directories created at this
level in the future.
I would like to be able to resue the foreach (String RFile in RFiles) block without repeating the 4 times.
Thus can you show me how to modify this code and/or tell me how I can change this code?
public String addNewPKG()
{
{
try
{
String packageId = "";
int intReviewFileCount = 0;
string Format_year = DateTime.Now.AddMonths(-1).ToString("yyyy");
string strMonth = DateTime.Now.AddMonths(-1).ToString("MMMM").ToUpper();
string Format_Date = "_" + strMonth.Substring(0, 3) + "_" + Format_year;
String filesaveLocation = null;
filesaveLocation = Path.Combine(ConfigurationSettings.AppSettings["tLocation"], Format_Date);
string strCancel = "Cancel";
string strED = "ED";
string strUI = "UI";
string strRCS = "RCS";
string strsubfilesaveLocation = Path.Combine(filesaveLocation, strRCS);
if (!Directory.Exists(strsubfilesaveLocation))
{
System.IO.Directory.CreateDirectory(strsubfilesaveLocation);
logging.Error("The location " + strsubfilesaveLocation + " does not exist for documents. ");
return packageId;
}
else
{
string[] RVWFiles = (from path in Directory.GetFiles(strsubfilesaveLocation)
let name = Path.GetFileName(path)
where name.EndsWith(".pdf") ||
name.EndsWith(".xlsx") ||
name.EndsWith(".xls")
select path).ToArray();
if (RVWFiles.Length == 0)
{
logging.Info("packageId: " + packageId + " the location " + strsubfilesaveLocation + " does not contain any documents. ");
return packageId;
}
foreach (String RFile in RFiles)
{
string orgnizationName = "";
string contactName = "";
string fileNameWithExtension = Path.GetFileName(RFile);
string fileName = Path.GetFileNameWithoutExtension(RFile);
string Original_location = filesaveLocation;
string[] names = fileName.Split('_');
orgnizationName = names[0].TrimEnd();
contactName = names[1].TrimStart();
string strOrgnizationName = orgnizationName;
string[] items = contactName.TrimEnd().Split(' ');
string surname = items[items.Length - 1];
--here does the processing that is required--
return null;
}
}
catch (Exception e)
{
logging.Error("Error Processing --> " + e.Message);
logging.Error("************* Stack Trace *******************");
logging.Error(e.StackTrace);
throw new Exception(e.Message);
}
}
}
|
|
|
|
|
Why wouldn't you just put a foreach directory loop around the GetFiles loop?
|
|
|
|
|
Hi,
I just refactored your code, it goes through your root dir and look for the sub dirs that you wanted and check for the files you wanted. If you want to change the sub dirs or add new sub dirs, you just need to edit the "SubDirNames" array.
private string[] SubDirNames = new string[]
{
"Cancel",
"ED",
"UI",
"RCS"
};
private List<string> GetSubDirectoryPaths(DirectoryInfo rootDir)
{
List<string> subDirs = new List<string>();
foreach (string subDirName in SubDirNames)
{
DirectoryInfo[] dirs = rootDir.GetDirectories(subDirName);
if (dirs.Length > 0)
{
subDirs.Add(dirs[0].FullName);
}
else
{
string path = Path.Combine(rootDir.FullName, subDirName);
Directory.CreateDirectory(path);
logging.Error("The location " + path + " does not exist for documents. ");
}
}
return subDirs;
}
private string[] GetFiles(string subDir)
{
return (from path in Directory.GetFiles(subDir)
let name = Path.GetFileName(path)
where name.EndsWith(".pdf") ||
name.EndsWith(".xlsx") ||
name.EndsWith(".xls")
select path).ToArray();
}
public string addNewPKG()
{
try
{
string packageId = "";
DateTime myDateTime = DateTime.Now.AddMonths(-1);
string fromDate = "_" + myDateTime.ToString("MMM").ToUpper() + " _" + myDateTime.ToString("yyyy");
string rootDirPath = Path.Combine(ConfigurationSettings.AppSettings["tLocation"], fromDate);
DirectoryInfo rootDir = new DirectoryInfo(rootDirPath);
if (!rootDir.Exists)
{
rootDir.Create();
logging.Error("The location " + rootDirPath + " does not exist for documents. ");
return packageId;
}
else
{
List<string> subDirPaths = GetSubDirectoryPaths(rootDir);
foreach (string subDir in subDirPaths)
{
string[] RVWFiles = GetFiles(subDir);
if (RVWFiles.Length > 0)
{
foreach (string RFile in RVWFiles)
{
string orgnizationName = "";
string contactName = "";
string fileNameWithExtension = Path.GetFileName(RFile);
string fileName = Path.GetFileNameWithoutExtension(RFile);
string Original_location = subDir;
string[] names = fileName.Split('_');
orgnizationName = names[0].TrimEnd();
contactName = names[1].TrimStart();
string strOrgnizationName = orgnizationName;
string[] items = contactName.TrimEnd().Split(' ');
string surname = items[items.Length - 1];
}
}
else
{
logging.Info("packageId: " + packageId + " the location " + subDir + " does not contain any documents. ");
return packageId;
}
}
}
}
catch (Exception e)
{
logging.Error("Error Processing --> " + e.Message);
logging.Error("************* Stack Trace *******************");
logging.Error(e.StackTrace);
return packageId;
}
return null;
}
There are few other things, I an not sure about your "PackageId" variable, this is empty at the moment; and why are you returning the packageId when error occurs and returning "null" when success?
Second, don't throw exception on exception, it is pointless, either handle the exception or let the compiler does what it does best.
Third, if i were you, I would move the processing part of the file into a separate method too for better readability.
I hope this helps.
Regards
Jegan
Think! Don't write a line of code unless you absolutely need to.
modified 10-Mar-13 20:22pm.
|
|
|
|
|
Thank you for your answer!
I placed the value for the packageid in the worn locations!
|
|
|
|