|
|
Hello,
VS 2008 SP1
I have a created a small application that records and plays audio. However, my application needs to save the wave file to the application data directory on the users computer.
The mciSendString takes a C style string as a parameter and has to be in 8.3 format. However, my problem is I can't get it to save. And what is strange is sometime it does and sometimes it doesn't. However, most of the time it failes. However, if I save directly to the C drive it works first time everything. I have used 3 different methods that I have coded below.
The error number that I get when it fails is 286."The file was not saved. Make sure your system has sufficient disk space or has an intact network connection"
[DllImport("winmm.dll",CharSet=CharSet.Auto)]
private static extern uint mciSendString([MarshalAs(UnmanagedType.LPTStr)] string command,
StringBuilder returnValue,
int returnLength,
IntPtr winHandle);
[DllImport("winmm.dll", CharSet = CharSet.Auto)]
private static extern int mciGetErrorString(uint errorCode, StringBuilder errorText, int errorTextSize);
[DllImport("Kernel32.dll", CharSet=CharSet.Auto)]
private static extern int GetShortPathName([MarshalAs(UnmanagedType.LPTStr)] string longPath,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath,
int length);
private void StopRecording()
{
string shortPath = this.shortPathName();
string formatShortPath = string.Format("save recsound \"{0}\"", shortPath);
uint result = 0;
StringBuilder errorTest = new StringBuilder(256);
result = mciSendString(string.Format("{0}", formatShortPath), null, 0, IntPtr.Zero);
mciGetErrorString(result, errorTest, errorTest.Length);
result = mciSendString("save recsound \"C:\\DOCUME~1\\Steve\\APPLIC~1\\Test.wav\"", null, 0, IntPtr.Zero);
mciGetErrorString(result, errorTest, errorTest.Length);
result = mciSendString(@"save recsound C:\DOCUME~1\Steve\APPLIC~1\Test.wav", null, 0, IntPtr.Zero);
mciGetErrorString(result, errorTest, errorTest.Length);
result = mciSendString(@"save recsound C:\Test.wav", null, 0, IntPtr.Zero);
mciGetErrorString(result, errorTest, errorTest.Length);
mciSendString("close recsound ", null, 0, IntPtr.Zero);
}
private string shortPathName()
{
string shortPath = string.Empty;
long length = 0;
StringBuilder buffer = new StringBuilder(256);
length = GetShortPathName(this.saveRecordingPath, buffer, 256);
shortPath = buffer.ToString();
return shortPath;
}
|
|
|
|
|
can we make printable grid of simple dot net grid, and can we print our form objects with grid? I am trying to create my own report builder for C# forms application
|
|
|
|
|
We have a sales program that allows the user to view the sales report on screen, contained in a paged GridView . The user has the option to print the report. When they select 'Print', the code:
1. Modifies the GridView to display all rows (vs. paging) by changing the PageSize property.
2. Hides all extraneous page elements by modifying their Visible properties.
3. Changes the page's Theme from a screen oriented theme to a theme optimized for printing by modifying (Page.Theme and Page.StylesheetTheme ) properties.
4. Calls the browser's print command via JavaScript.
Hopes this helps answer your question.
Regards,
Gary
|
|
|
|
|
Hi All!!
I want to display images from the database into 3 x 3 table...
The scenario is:
1. I have 3 x 3 table
2. Read Image from database.
3. Dispay it in the table
How should i manage it?? I have done image reading from database but could not display it into the table...If i take image independently and display it on the web form then it goes ok but can't display in the table...guide me please!!
|
|
|
|
|
Which control do you mean by "table"?
|
|
|
|
|
I do not mean any control. I have to draw a table of 3 rows and 3 columns then i have to print image in every position of the table
|
|
|
|
|
Hi, this is my first post on CodeProject.
I searched for months how to do this, but I didn't find anything that works.
Well, I want to connect 2 computers. Just to say "hello world" and receive this.
I used sockets and it works. On LAN.
But I want to do this on WAN.
I heard about UPnP, NAT Transversal; but no one of the examples given works.
For example,
NAT Traversal with UPnP in C#[^] didn't work,
Neither Woodchop.Net.UPnP,
Neither NATUPnP 1.0 Type Library of Chris Pietschmann.
If I can connect these computers with another technology, please, let me know.
Thanks for reading
|
|
|
|
|
AFAIK you can use Web services for communication between two computers over internet.
|
|
|
|
|
In order to use a WebService, I want to host my application on a server.
But, I want to simple connect the computers, like on a instant messenger.
For example:
10.0.0.1 ----- 208.67.256.xx == 208.67.249.yy ----- 192.168.0.1
| |
10.0.0.5 192.168.0.127
What can I do to connect 10.0.0.5 with 192.168.0.127, using Sockets and another technology?
|
|
|
|
|
Does this[^] article helps?
|
|
|
|
|
Yes, this code works on a LAN connection.
But what should I do to connect computers over a WAN (Internet) connection?
Port forwarding would be an answer, but I couldn't do this in C#.
|
|
|
|
|
Hi, that first article would be mine, in what way doesn't it work? (can't fix what I don't know about )
|
|
|
|
|
Sure.
Well, when I use the UPnP.NAT.Discover() method,
the program stucks on the 44th line of the class:
length = s.Receive(buffer);
I don't know why.
Maybe, the UPnP feature on the router is disabled. (because I don't have access to it [ISP router])
But, if it is the problem, please tell me another way to forward ports..
Thanks.
|
|
|
|
|
Do you have µTorrent installed? It uses almost the same method of port forwarding as I do in that article (because, well, that's how I figured out how to do it..)
So that would be a simple way to test whether your router supports UPnP - enable the UPnP feature and look in the log for UPnP errors, if there are any then there's not much you can do, apart from switching ISPs I suppose..
There is an other way to forward ports called NAT-PMP but it's not used in practice.
|
|
|
|
|
In uTorrent I can download normally the torrents, but the site http://www.utorrent.com:16000/testport?port=37218[^] says that "An error has occurred!".
Do you have any idea what type of forward MSN Messenger uses?
I'll search about the "NAT-PMP" anyway, thank you.
|
|
|
|
|
Hm ok, I don't know what MSN does, but whatever it does it would only be needed for file transfer and voice/cam - normal messages are routed through MS (there goes your privacy..)
I'll look into it when I have more time to run tests
|
|
|
|
|
OK, thank you.
If I found anything, I'll post here.
|
|
|
|
|
Ok cool
Oh btw, have you looked at Mono.Nat? I didn't have too much luck with it, but several people have recommended it in the past and it's free anyway..
|
|
|
|
|
No, I haven't. Thanks, I'll give a look at this project!
|
|
|
|
|
First, sorry for my poor english
If u want connect two computer through internet for your application(using socket programming or wcf). U must open port of your modem.
Example: server application use port 8080 to listen client connect to. U must open port 8080.
To open port, run cmd, type ipconfig, enter. The default getway is Ip of modem. Type this IP on IE or FireFox... to access modem, (require usename and password). U cant find the way to open port modem here http://portforward.com/[^]
Client app can connect to your server app if it use correct global IP and port, u can use this page to know your global IP (dynamic IP) http://ip2location.com
Note: if u test your app, both client and server on a computer or computers on LAN, u cant use this global IP (instead LAN IP, or loopback IP). U can get your friend(certainly, use a computer connected internet) to help you.
IF ur app use wcf, u must set security mode in config file to "none" (this is the easiest way ).
|
|
|
|
|
But.. If I can't access the router/modem?
With this example, I can connect a computer to a gateway.
I want to gateway could redirect this connection to a sub-network computer.
I'll search more about WCF, I don't know what it is.
Thank you!
|
|
|
|
|
I want to add button like the following screen shot in my application with VC#. It's from Firefox with Glasser. Can anyone help?
Screenshot
|
|
|
|
|
|
|