|
Hi,
Just a few things :
- Try to be as accurate as possible when you ask for something. Noone will try to guess what is exactly the problem if you do not dare to describe precisely what you have done, what you are expecting and what is going wrong.
- Do not post the same question twice ; it is a rude attitude, and it make things much harder for people who want to follow the flow of the post if answers are scattered between several posts.
|
|
|
|
|
hi for all
I want select a file in my disk by openfiledialog tool in vb.net
then copy selected file in a special path with any format please guide me thanks.
|
|
|
|
|
faravani wrote: hi for all
Goodmorning
faravani wrote: I want select a file in my disk by openfiledialog tool in vb.net
That's done using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx">OpenFileDialog</a>[<a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx" target="_blank" title="New Window">^</a>] class. Call it's ShowDialog method to show it, and retrieve the path of the file that the user selected using it's <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.filedialog.filename.aspx">FileName</a>[<a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.filedialog.filename.aspx" target="_blank" title="New Window">^</a>] property.
faravani wrote: then copy selected file
That's done using the <a href="http://msdn.microsoft.com/en-us/library/c6cfw35a.aspx">Copy</a>[<a href="http://msdn.microsoft.com/en-us/library/c6cfw35a.aspx" target="_blank" title="New Window">^</a>] method of the File class. Do remember to check the exceptions that it might throw.
faravani wrote: <layer>in a special path
You can use each directory. If you need to fetch the directory of a folder, consider using the <a href="http://msdn.microsoft.com/en-us/library/system.environment.getfolderpath.aspx">GetFolderPath</a>[<a href="http://msdn.microsoft.com/en-us/library/system.environment.getfolderpath.aspx" target="_blank" title="New Window">^</a>] method
faravani wrote: with any format
It would copy the data there, provided that it's accessible (you have the appropriate rights, not locked by another process etc.)
Hope this helps
Bastard Programmer from Hell
|
|
|
|
|
Cannot get any clearer than that .
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
Good answer.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Thanx
|
|
|
|
|
I have a situation with inheritance. In my base class I have a function GetName() which I want to supply the name of the class that calls the function. But how do I give the name of my current subclass and not the base class? This is my code so far.
Class Base
Public Function GetName() As String
' Bad code
'Return System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name.ToLower()
' Good code
Dim type as Type = Me.GetType()
Return type.Name
End Function
End Class
Class Sub
Inherits Base
' Some unrelated code
End Class
' In program somewhere
Dim s as Sub
Console.PrintLine(s.GetName()) ' should print out Sub, but it prints Base
EDIT: I found the solution. about 30 minutes after this post, I found it. Adjusted the code.
modified on Wednesday, June 8, 2011 9:43 AM
|
|
|
|
|
Hope this helps;
Class Base
Public Function GetClassName() As String
Return System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name.ToLower()
End Function
Public Function GetCallingMethodName() As String
Return New StackTrace().GetFrame(1).GetMethod().Name
End Function
Public Function GetMethodName() As String
Return New StackTrace().GetFrame(0).GetMethod().Name
End Function
End Class
Class SubClass
Inherits Base
End Class
Module Module1
Sub main()
Dim s As New SubClass
Console.WriteLine(s.GetClassName())
Console.WriteLine(s.GetCallingMethodName())
Console.WriteLine(s.GetMethodName())
Console.ReadKey()
End Sub
End Module
Bastard Programmer from Hell
|
|
|
|
|
The Reflection will give you the "Base" name. The StackTrace would give you the name of the calling Mehtod. I needed the name of the type of the subclass.
I know Sub is not a valid name, but I was making a quick example program, my actual program is a lot more complex, but I just needed the type of the subclass.
|
|
|
|
|
if you want information about the caller, Environment.StackTrace may be useful.
if you want information about the base class of some object, look at Object.GetType().
and then there is reflection.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Thanks mate, I needed the Object.GetType(), used Me.GetType() works too. Thanks for the help, both of you!
|
|
|
|
|
Hi,
I have to run crystal reports runtime before/after installing a new vb.net project on a user's pc. How can I include the automatic installation of crystal reports runtime file when deploying a project onto a user's pc e.g. run CRRedist2008_x86.msi. I know this can be done but how?
Thanks in advance.
|
|
|
|
|
You either have to include the CrystalReport merge modules in your .MSI or you have to create a setup wrapper (Setup.exe), otherwise called a bootstrapper, to install each .MSI. If you're installing the .NET Framework with your application, the Setup.exe cannot be written in managed code (i.e.: VB.NET or C#).
|
|
|
|
|
|
Hi,
I have a program written in VB 6.0 for sending automated mails using CDO object.
Suddenly it stopped working. I am giving the code below. What could be the possible reason for this program to stop working suddenly.
Public Sub SendOutlookMail(Subject As String, Recipient As String, Sender as String, strHTML As String)
Dim iMsg As New CDO.Message
On Error GoTo ErrHdlr
Const cdoSendUsingPort = 2
' Apply the settings to the message.
With iMsg
.To = Recipient 'Recipient 'Recipient 'ToDo: Enter a valid email address.
.From = Sender
.Subject = Subject
.HTMLBody = strHTML
.Send
End With
' Clean up variables.
Set iMsg = Nothing
Exit Sub
ErrHdlr:
Exit Sub
End Sub Regards,
Uma
modified on Tuesday, June 7, 2011 8:33 AM
|
|
|
|
|
Uma Kameswari wrote: Suddenly it stopped working
Include the error message in your question. BTW format the code using Code block in the question
|
|
|
|
|
No error message. When I execute the program with break points it is not throwing any error. it is executing successfully. but mails are not received.
|
|
|
|
|
I notice that when you catch any error you merely exit from the subroutine. This is extremely bad practice as it means you just eat any exception that occurs rather than using the information provided to diagnose why your code is failing.
The best things in life are not things.
|
|
|
|
|
As I already said I traced the code it is not throwing any exception. The best practice is to write a logfile. I agree with you.
|
|
|
|
|
Check your CDO configuration values as described here[^]. Also in the following line:
Const cdoSendUsingPort = 2
the variable is never referenced in your code, why is it there?
The best things in life are not things.
|
|
|
|
|
this is a code written 8 yrs back by another user. As it was working we did not review it. Now what is the reason for the mails not getting delivered suddenly. till last tuesday it was working fine and suddenly it stopped working.
|
|
|
|
|
Something must have changed, but it is impossible to determine the problem without being able to access your system and run it through the debugger. So, I guess it's up to you.
The best things in life are not things.
|
|
|
|
|
Is it always (mainly) the same message to the same address ?
If your code is not throwing any errors, the most likely reason for the message not arriving is not your code.
You should test the app by adding your own address to the BCC field, and see if you receive the message.
And/or you may want to look into the following things:
1. the recipient's address has changed or has been deleted, and your app is sending the message to the old address.
2. the recipient's email program has interpreted the message as being SPAM, and is now blocking it.
3. the recipient's email operator uses a (new) SPAM blocking service, which has interpreted your messages as SPAM and is now blocking them.
4. the mail server you send messages through has changed (new server ?)
My advice is free, and you may get what you paid for.
|
|
|
|
|
It is not the same message but it is a report in the same format. and to the same address.
I just now tried by including my address in BCC but still I did not receive the mail.
The mail server has changed 2 months before. Even after changing the mail server the program was sending mails properly and suddenly 1 fine day it stopped sending mails. Subject is same to the mail and also the sender address is same. So if suppose it is identified as SPAM by the server how can we resolve this. As the program is not generating any error logically it seems to be a problem at mail server level. How to resolve this?
|
|
|
|
|
The first thing you could try is to manually create a similar message in your regular email client (same recipients including yourself, same subject, same body text, same attachments). See if that message does arrive.
Another thing you could check is the Sender address (the From field). Does this address exist ? If the manual message did arrive, was the sender address the same as the one used by your code ?
My advice is free, and you may get what you paid for.
|
|
|
|