|
Hi
I am new to C# and am still learning I am trying to merge data from iether 1 or multiple coloumns of a data file to x & y coordinates in a pdf file ive downloaded itextsharp but am not sure where best to begin any suggestion appreciated also want to call in font downloaded off internet.
Thanks & regards
|
|
|
|
|
Member 9155359 wrote: but am not sure where best to begin
Somewhere like this[^], where you should find some useful samples and tutorials.
|
|
|
|
|
I am trying to annotate an existing pdf document, however, i can only open the document readonly mode, it doesn't edit or annotate it, on the other hand, i can only create a pdf and overwrite my version. What is the problem?
|
|
|
|
|
candogu wrote: What is the problem?
Impossible to say without a lot more information.
|
|
|
|
|
If it's only one PDF that is like this, then it means it's been saved as a read only PDF. If it's a problem with all external PDFs, then it's your code that's at fault.
|
|
|
|
|
i want to display large content i.e data may be 50 to 60 mb for example bible in desktop application.how i can do that?
|
|
|
|
|
Like it says in "how to ask a question", choose THE correct forum. THE means one, not two or more.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
In a C# 2010 application, I have a string value that looks like the following:
"http://localhost:99/test/TestHome.aspx". I only want to obtain the part of the string that is "TestHome.aspx".
I have tried lots of string functions to obtain the "TestHome.aspx" part of the string with no success yet.
Thus can you tell me how to obtain the part of the string I am trying to access?
|
|
|
|
|
There are many ways you could accomplish this. You could use a regular expression (a sledgehammer to crack a nut). You could use string.LastIndexOf to find the last / and then do a Substring based off this, or you could do a string.Split and take the last item out of the array.
|
|
|
|
|
Use System.IO.Path.GetFileName("http://localhost:99/test/TestHome.aspx")
|
|
|
|
|
Good one! My first impression was "that's a URL, not a path. It'll never work." Then I tried it.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
GetFileName is a good choice, but it does have the limitation of that it is actually doing more than is necessary to solve this particular problem. Why is that you ask? Well, when we deconstruct the method, it actually does the following:
public static string GetFileName(string path)
{
if (path != null)
{
CheckInvalidPathChars(path);
int length = path.Length;
int num2 = length;
while (--num2 >= 0)
{
char ch = path[num2];
if (((ch == DirectorySeparatorChar) || (ch == AltDirectorySeparatorChar)) || (ch == VolumeSeparatorChar))
{
return path.Substring(num2 + 1, (length - num2) - 1);
}
}
}
return path;
} As you can see, right at the top of the method, it's calling CheckInvalidPathChars to determine whether or not the path is valid. However, this is just a minor point - yours is a perfectly good solution, hence my 5.
|
|
|
|
|
Don't worry about anything, single one line code will solve problem,
i have complete program for you:
String s = "http://localhost:99/test/TestHome.aspx";
s = Path.GetFileName(s.Replace("/", "\\"));
Console.WriteLine(s);
Console.ReadKey();
|
|
|
|
|
|
GetFileName is a crap choice, doesn't sound very portable at all and there is a class dedicated to Uri handling already :P
Votes of 1 all around on this
Surely you'd do
var result = new Uri("http://foo.com/foo.aspx").Segments.Last();
|
|
|
|
|
So, an even less efficient method to retrieve this then. As the OP hasn't stated they are doing anything else Uri, it's kind of a waste when you end up with this method
public string[] Segments
{
get
{
int index;
if (this.IsNotAbsoluteUri)
{
throw new InvalidOperationException(SR.GetString("net_uri_NotAbsolute"));
}
string[] strArray = null;
if (strArray != null)
{
return strArray;
}
string privateAbsolutePath = this.PrivateAbsolutePath;
if (privateAbsolutePath.Length == 0)
{
return new string[0];
}
ArrayList list = new ArrayList();
for (int i = 0; i < privateAbsolutePath.Length; i = index + 1)
{
index = privateAbsolutePath.IndexOf('/', i);
if (index == -1)
{
index = privateAbsolutePath.Length - 1;
}
list.Add(privateAbsolutePath.Substring(i, (index - i) + 1));
}
return (string[]) list.ToArray(typeof(string));
}
} I'll be nice though. I won't award you a 1.
|
|
|
|
|
Path.GetFileName() is prefectly reasonable given the problem as described.
It describes the (apparent) intent, and so adds to the clarity of the code, which increases maintainability.
It is not necssarily the most efficient solution, but if done in response to user interaction, is probably plenty fast to not cause a performance issue.
|
|
|
|
|
A combination of the substring and IndexOf functions should be enough.
String.Split is the other neat option.
|
|
|
|
|
You could always use the System.Uri [^] class, which can provide much more information for you.
|
|
|
|
|
I'd use LastIndexOf and Substring, unless you actually want the extra validation of a path or URL parsing function.
|
|
|
|
|
Hello,
Try this:
Uri myUrl = new Uri("http://localhost:99/test/TestHome.aspx");
string pagina = myUrl.Segments.Last();
att.
Ernesto Fazolo
modified 22-Jun-12 13:09pm.
|
|
|
|
|
How can i create a tool with an windows media player and a playback device choiser like this..
http://www.abload.de/img/unbenannt-290mk6.png
(this is from teamspeak 3)
I got already a media player in my program and can play tracks with it, but the sound come all the time over my headset. I want to set that my program sound goes over the speaker. Someone know how to make this release?
Thanks for your help and sorry for my english
modified 2-Jul-12 8:04am.
|
|
|
|
|
here is the problem which I come across with:
I want to get process name ,application name and it's window title name
with the code below
listView1.Columns.Add("CurrentProcess", 2000);
listView1.Columns.Add("CurrentProcessPID", 500);
listView1.Columns.Add("CurrentApplicationname", 2000);
listView1.Items.Insert(1,Process.GetCurrentProcess().ToString());
listView1.Items.Insert(2,Process.GetCurrentProcess().MainWindowTitle);
listView1.Items.Insert(3,Process.GetCurrentProcess().Id.ToString());
but when I run my code I get this result
system.diagnostics.process(currentApplication on ByPId.vshost) form1
I enter this code to run in a timer tick so I use other application in the middle of this running code but I just get the result above.
I would appreciate any commend
|
|
|
|
|
whenever your app does something, it IS the current process. Therefore, GetCurrentProcess() isn't going to help you getting information about other processes.
The Process class does hold what you need, however, be aware there are a number of system processes you are not allowed to get information about (You would get some kind of access violation when you try). An alternative route would be using WMI, probably with the exact same limitations.
|
|
|
|
|
thanks a lot;
I would like to write an application to run at the back ground( I mean do such thing except for itself);
do you recommend any thing?
|
|
|
|