|
Member 10410972 wrote: I need a better solution. Better in what way? You need to explain what problem you are trying to solve.
|
|
|
|
|
Thank you.
I really need the code for savefiledialog1 with encoding as:
SaveFileDialog saveFileDialog = new SaveFileDialog();<br />
saveFileDialog.InitialDirectory = "@:\\";<br />
saveFileDialog.Filter =<br />
"ANSI encoding (*.*)|*.*|"<br />
+ "Unicode (UTF-8) encoding (*.*)|*.*|"<br />
+ "Unicode encoding (*.*)|*.*|"<br />
+ "All files (*.*)|*.*";
(My textBob is textBox2.Text)
Please look at the picture:
http://www.dodaj.rs/f/i/9b/orO7WE9/1.png
Please help me! Thank you.
|
|
|
|
|
SaveFileDialog has nothing to do with it, it is just a dialog that gets a filename from the user. You save data to a file by using something like the StreamWriter class[^]. You should read the documentation to find out which options to use for what you want to achieve.
|
|
|
|
|
Doesn't look too bad to me, except for the part about calling your Unicode encoding 'ascii'.
How about using StreamWriter? The constructor takes an encoding and has methods to write strings so you can do away with the byte array stuff.
Regards,
Rob Philpott.
|
|
|
|
|
Hello guys!
This is my code:
private void openToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
OpenFileDialog openFileDialog1 = new OpenFileDialog();<br />
openFileDialog1.Title = "";<br />
openFileDialog1.InitialDirectory = "c:\\";<br />
openFileDialog1.FileName = null;<br />
openFileDialog1.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";<br />
openFileDialog1.FilterIndex = 1;<br />
openFileDialog1.RestoreDirectory = true;<br />
DialogResult result1 = openFileDialog1.ShowDialog();<br />
string file1 = openFileDialog1.FileName;<br />
if (result1 == DialogResult.OK)<br />
{<br />
Encoding enc = Encoding.GetEncoding("Windows-1251 && Windows-1250");<br />
string s = File.ReadAllText(file1, enc);<br />
textBox1.Text = s;<br />
}<br />
<br />
}
The problem with this code:
Encoding enc = Encoding.GetEncoding("Windows-1251 && Windows-1250");
Please see the image:
http://www.dodaj.rs/f/3Z/O6/1uQ1dcT1/33.png
I need the Windows-1250 and Windows-1251. What is the solution? Thank you!
|
|
|
|
|
|
Okay I understand. Thank you!
|
|
|
|
|
use like this ...
// Get a UTF-32 encoding by name.
Encoding e2 = Encoding.GetEncoding( "utf-32" );
|
|
|
|
|
Hi,
I have SMS gateway and they only allow SMPP protocol to be used to send SMSs.
Is it possible to send use SMPP using just C# .NET Framework or I should use a third party?
if not possible, any free third-party?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
|
You asked the very same question on t 1st of November - what about the answers there?
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
hi,
im developing a list page which has more than 20 columns.i know its bit long.so i want to make it more flexible,the idea is..i want the user to select which columns they need to see in the list.n based on their selection data must be bring back from the back end(only
the selected columns).we have a very huge database so.i want to make very optimized request..please suggest a best way to implement this
|
|
|
|
|
So what is your problem here.
Step 1:
Place a link or button on top of List.
When user click open a popup window load column name from sql to gridview wich check box column.
here is query to load all column name from a table.
SELECT Column_name
FROM information_schema.columns
WHERE table_name = 'YourTable_Name'
ORDER BY ordinal_position
From popwindow get all the selected column name and display the selected column in your main form.
Step 2:
By default load all columns and make visible selected columns .
Place a link or button on top of List.
When user click open a popup window load column name from sql to gridview wich check box column.
here is query to load all column name from a table.
<pre lang="SQL">
SELECT Column_name
FROM information_schema.columns
WHERE table_name = 'YourTable_Name'
ORDER BY ordinal_position
</pre>
From popwindow get all the selected column name and make visible tru and false for the selected columns.
|
|
|
|
|
Please post your question in only one forum at a time.
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
Select required fields and append in a string variable spreading by coma(,) then it's pass Select Query Command .
|
|
|
|
|
Hey,
i was working on some API for networking when i implemented some sort of logging and Reporting, in certain situations when all of the sudden my Test project in WPF didn't worked as expected. After some debugging i found a Cross-Thread exception that was caused by some bindings. The API is using some High Level of threading and Tasking support.
The problem was that i was attached to a Event that was trigger in a Non-Dispatcher Thread, and inside my ViewModel i did not synchronized the code. The Whole application was still running ( AppDomain had some global exception Handling ) but the point is, this external exception ( as seen from the API side ) had noting to do with the API but prevented it from working by throwing an Exception and stops the execution of the code after the Event Trigger.
I learned due my time as a Developer that some sort of "General" exception catching should be prevented where possible. This does not mean an empty TryCatch block ( What is actually even very Bad ).
So my Question is:
Should i break this Design guide and more, should i catch Exceptions in general when i Invoke an event? The event handler could Throw some exceptions what i do not expect and i should not worry about. And last but not least: If jes, what to do when we catch an event?
|
|
|
|
|
Jean-Pierre Bachmann wrote: should i catch Exceptions in general when i Invoke an event? Nah. If you did and an exception occurs, how would I even know?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
My problem is about how to call a c# function like this
string Block = "1111111111";
string a = "87654321";
string m = "2222";
string c = "11";
string u = "99";
string v = "00";
byte[] result = W(
SoapHexBinary.Parse(a).Value,
SoapHexBinary.Parse(m).Value,
SoapHexBinary.Parse(v).Value[0],
SoapHexBinary.Parse(u).Value[0],
SoapHexBinary.Parse(c).Value[0],
SoapHexBinary.Parse(Block).Value
);
from VB.NET
Dim Block As String = "AAAAAAAAAA"
Dim a As String = "99999999"
Dim m As String = "3333"
Dim a As String = "77"
Dim u As String = "07"
Dim v As String = "00"
Dim result As String = ""
result = W(a, m, v, u, a, Block)
a, m and Block are not accepted.
I'm not a C# expert so I guess that there is something to be done in order to correctly address strings and arrays between the two languages. Must be kind of basic rule I ignore...
Anybody can help?
Thanks in advance.
Seppax
|
|
|
|
|
|
You're not calling it the same way as the C# code. Without knowing anything about what W is, the equivalent code would be:
Dim Block As String = "AAAAAAAAAA"
Dim a As String = "99999999"
Dim m As String = "3333"
Dim a As String = "77"
Dim u As String = "07"
Dim v As String = "00"
Dim result As byte() = W(
SoapHexBinary.Parse(a).Value,
SoapHexBinary.Parse(m).Value,
SoapHexBinary.Parse(v).Value(0),
SoapHexBinary.Parse(u).Value(0),
SoapHexBinary.Parse(c).Value(0),
SoapHexBinary.Parse(Block).Value
)
modified 19-Dec-14 8:12am.
|
|
|
|
|
Thanks Dave,
W is like below
Public Shared Function W(a() As Byte, m() A s Byte, v As Byte, u As Byte, u As Byte, block() As Byte) As Byte()
It seems to been accepted now exectp getting an error on the
SoapHexBinary.Parse(c).Value[0] param
where 'an identificator is needed for 0'
|
|
|
|
|
Whoops. I forgot to change the square brackets to parenthesis.
|
|
|
|
|
so it's SoapHexBinary.Parse(c).Value(0)
right, you got it, this seems solved.
But now VB.NET is arguing about
a, m and Block...
Dim result As Byte() = W(SoapHexBinary.Parse(a), SoapHexBinary.Parse(m), SoapHexBinary.Parse(v).Value(0), SoapHexBinary.Parse(u).Value(0), SoapHexBinary.Parse(n).Value(0), SoapHexBinary.Parse(Block))
(translated)
Can't convert the type value 'System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary' into a 1 byte dimension matrix.
Hope you can help again.
Thks
Seppax
|
|
|
|
|
Solved.... had it under the eyes for the whole time...
a, m and Block misse the .Value property!
Dim result As Byte() = W(SoapHexBinary.Parse(a).value, SoapHexBinary.Parse(m).value, SoapHexBinary.Parse(v).Value(0), SoapHexBinary.Parse(u).Value(0), SoapHexBinary.Parse(n).Value(0), SoapHexBinary.Parse(Block).value)
|
|
|
|
|
When i chose a file to up load it says
Object reference not set to an instance of an object. .
protected void DocumentUpload_OnFileUploadComplete(object sender, FileUploadCompleteEventArgs e)
{
if (!e.UploadedFile.IsValid) return;
GridViewDetailRowTemplateContainer container = ((Control)sender).NamingContainer as GridViewDetailRowTemplateContainer;
Int32 index = container.VisibleIndex;
var orderId = Convert.ToInt32(ViewOrdersGridView.GetRowValues(index, ViewOrdersGridView.KeyFieldName));
var fileNumber = ViewOrdersGridView.GetRowValues(index, ElsaConstants.FileNumber).ToString();
var userId = Convert.ToInt32(Session[ElsaConstants.UserId]);
string directory = ConfigurationManager.AppSettings[ElsaConstants.UploadDirectory];
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
string fileType = Path.GetExtension(e.UploadedFile.FileName);
string fileName = e.UploadedFile.FileName.Replace(fileType, string.Format("_{0}{1}", fileNumber, fileType));
string resultFilePath = directory + fileName;
e.UploadedFile.SaveAs(resultFilePath, true);
using (var context = new ELSAEntities())
{
var document = new Document
{
OrderId = orderId,
DocumentPath = fileName,
DateCreated = DateTime.Now,
CreatedBy = userId
};
context.Document.Add(document);
context.SaveChanges();
}
}
modified 18-Dec-14 12:16pm.
|
|
|
|