|
Try DELETING the web service reference and then re-adding it again (in the upgraded project).
Changing the .NET version of an existing project with an existing web service reference does not automatically "upgrade" the web reference.
modified 28-Aug-14 11:40am.
|
|
|
|
|
hi to all
i want wrote a one line Code Similare This
myDataTable.Select("Guid IN ('8556c1fd-d4a1-4c1c-b2af-c1fa9403ce4e')")
but i face With this Problem
'myDataTable.Select("Guid IN ('8556c1fd-d4a1-4c1c-b2af-c1fa9403ce4e')")' threw an exception of type 'System.Data.EvaluateException' System.Data.DataRow[] {System.Data.EvaluateException}
this is a one line Code That is ok, but i dont want use of this Method
myDataTable.Select("Guid = '8556c1fd-d4a1-4c1c-b2af-c1fa9403ce4e'")
any way is Exist that Use Guid in Linq FilterExpresion With 'IN'????
thank for Any Help
|
|
|
|
|
Is the Guid in the database as a string representation or a byte [] ?
|
|
|
|
|
Guid save in DataBase AS UniqueIdentifier
|
|
|
|
|
That's most probably the culprit. This "UniqueIdentifier" is not a string and apparently your database engine cannot convert it implicitly. Try to follow Richard Deeming's advice. Alternatively you could use a parametrized query instead and try to pass the guid as a byte[] (blob) instead of a string.
Hope this helps.
|
|
|
|
|
Try converting the column to a string in the filter expression:
myDataTable.Select("Convert(Guid, 'System.String') IN ('8556c1fd-d4a1-4c1c-b2af-c1fa9403ce4e')")
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thanks Mr Deeming,Your Answer Save My life 
|
|
|
|
|
I've implemented a progress bar to my application but it makes the file copy process painfully slow whereas without the progress bar the copy is very fast. I know without the progress bar it only takes a few seconds to copy a 10 megabyte file but with the progress bar it takes more than a minute. What am I doing wrong?
namespace Compression_Util
{
class DropBox
{
private object sender;
private EventArgs e;
private DragEventArgs de;
private Design zip;
private string hover;
private string[] files;
private string filetype;
public DropBox(object sender, DragEventArgs de, Design zip, string hover)
{
this.sender = sender;
this.de = de;
this.zip = zip;
this.hover = hover;
this.Hover();
}
public DropBox(object sender, EventArgs e, Design zip, string hover)
{
this.sender = sender;
this.e = e;
this.zip = zip;
this.hover = hover;
this.Hover();
}
private void InitializeProgressBar(int fileSize)
{
zip.DropProgress.Visible = true;
zip.DropProgress.Minimum = sizeof(Byte);
zip.DropProgress.Step = sizeof(Byte);
zip.DropProgress.Maximum = fileSize;
}
private void DeInitializeProgressBar()
{
zip.DropProgress.Invalidate();
zip.DropProgress.Visible = false;
}
private void IncrementProgressBar()
{
zip.DropProgress.PerformStep();
}
private void CreateFile(string read, string write)
{
try
{
FileStream fileStreamReader = new FileStream(read, FileMode.Open, FileAccess.Read);
FileStream fileStreamWriter = new FileStream(write, FileMode.Create, FileAccess.ReadWrite);
BinaryReader binaryReader = new BinaryReader(fileStreamReader);
BinaryWriter binaryWriter = new BinaryWriter(fileStreamWriter);
int position = 0;
int length = (int)binaryReader.BaseStream.Length;
InitializeProgressBar(length);
while (position < length)
{
Byte line = binaryReader.ReadByte();
binaryWriter.Write(line);
position += sizeof(Byte);
IncrementProgressBar();
}
DeInitializeProgressBar();
binaryWriter.Close();
binaryReader.Close();
fileStreamWriter.Close();
fileStreamReader.Close();
}
catch (FileNotFoundException FileEx)
{
MessageBox.Show(FileEx.Message);
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
private string CreateFileName(string file)
{
int i = 0;
string deleteText = "";
string newFileName = "";
while ((i = file.IndexOf('.', i)) != -1)
{
deleteText = file.Substring(i);
i++;
}
this.filetype = deleteText;
newFileName = file.Replace(deleteText, ".xxx");
return newFileName;
}
private void Hover()
{
switch (this.hover)
{
case "Enter":
{
zip.DragLabel.Visible = false;
zip.DropLabel.Visible = true;
zip.BackColor = System.Drawing.Color.DarkGray;
zip.DropBox.BackColor = System.Drawing.Color.Thistle;
zip.DropBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
if (de.Data.GetDataPresent(DataFormats.FileDrop, false) == true)
{
de.Effect = DragDropEffects.All;
}
break;
}
case "Leave":
{
zip.DragLabel.Visible = true;
zip.DropLabel.Visible = false;
zip.BackColor = System.Drawing.Color.WhiteSmoke;
zip.DropBox.BackColor = System.Drawing.Color.WhiteSmoke;
zip.DropBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
break;
}
case "Drop":
{
zip.DragLabel.Visible = true;
zip.DropLabel.Visible = false;
zip.BackColor = System.Drawing.Color.WhiteSmoke;
zip.DropBox.BackColor = System.Drawing.Color.WhiteSmoke;
zip.DropBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.Drop();
break;
}
}
}
private void Drop()
{
this.files = (string[])this.de.Data.GetData(DataFormats.FileDrop);
foreach (string file in files)
{
string newFileName = this.CreateFileName(file);
if (!File.Exists(newFileName))
{
this.CreateFile(file, newFileName);
}
else
{
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result;
string message = "File already exists, Overwrite?";
string caption = "";
result = MessageBox.Show(zip, message, caption, buttons);
switch (result)
{
case DialogResult.Yes:
{
this.CreateFile(file, newFileName);
break;
}
case DialogResult.No:
{
MessageBox.Show("Operation has been cancelled!");
break;
}
default: break;
}
}
}
}
}
}
|
|
|
|
|
kiasta wrote: What am I doing wrong? You're performing UI operations during the copy. What you should instead do is use a BackgroundWorker[^] to perform the file copy and publish UI updates.
/ravi
|
|
|
|
|
Thanks for the reply! I will definitely look into that.
|
|
|
|
|
Not only are you copying the file in the UI, you are updating the progress bar every IO. I always calculate percent complete using the following formula: (number of bytes copied * 100) / size of file in bytes
All numbers used in the calculation are long but the result is converted to int. Update the progress bar only when the percent changes.
|
|
|
|
|
Hmm OK that makes some sense, but why would copying it inside the UI make any difference? Without the progress bar the files copy very fast, almost instantly. I don't really understand, I guess. Is the progress bar really that resource intensive?
|
|
|
|
|
As you said, the progress bar slows down the copy. The progress bar is CPU intensive while the file copy is most likely IO bound. The progress bar slows the copy when the two operations share the same thread. Copying the file in a separate thread will allow more efficient use of multiple processors; both operations run almost independently.
Also, try copying a file several gigabytes in size and watch your UI lock up.
I tend to reuse code a lot. Code a process right the first time and use it many times.
|
|
|
|
|
Ah OK I see now what you mean, thanks for the clarification!
|
|
|
|
|
 To add to what the others say, you are also doing this byte by byte!
Buffer it: allocate a buffer of say 1/2 meg and fill it. Write it, update progress. Fill it, write it, update progress.
But I do it in a background worker like this:
private void MoveFile(string src, string dst, BackgroundWorker worker = null, ProgressReport prMain = null)
{
if (src != dst)
{
int iSrc = src.IndexOf(':');
int iDst = dst.IndexOf(':');
FileInfo fiSrc = new FileInfo(src);
if (fiSrc.Length < blockSize || (iSrc > 0 && iDst > 0 && iSrc == iDst && src.Substring(0, iSrc) == dst.Substring(0, iDst)))
{
if (doCopyOnly)
{
File.Copy(src, dst);
}
else
{
File.Move(src, dst);
}
}
else
{
using (Stream sr = new FileStream(src, FileMode.Open))
{
using (Stream sw = new FileStream(dst, FileMode.Create))
{
long total = sr.Length;
long bytes = 0;
long cnt = total;
int progress = 0;
while (cnt > 0)
{
int n = sr.Read(transfer, 0, blockSize);
sw.Write(transfer, 0, n);
bytes += n;
cnt -= n;
int percent = (int)((bytes * 100) / total);
if (progress != percent)
{
progress = percent;
if (worker != null && prMain != null)
{
ProgressReport pr = new ProgressReport
{
FilesCount = prMain.FilesCount,
FileNumber = prMain.FileNumber,
Filename = prMain.Filename,
Action = prMain.Action,
FilePercentage = percent
};
worker.ReportProgress(-prMain.FileNumber, pr);
}
}
}
}
}
FileInfo fiDst = new FileInfo(dst);
fiDst.Attributes = fiSrc.Attributes;
fiDst.CreationTime = fiSrc.CreationTime;
fiDst.CreationTimeUtc = fiSrc.CreationTimeUtc;
fiDst.IsReadOnly = fiSrc.IsReadOnly;
fiDst.LastAccessTime = fiSrc.LastAccessTime;
fiDst.LastAccessTimeUtc = fiSrc.LastAccessTimeUtc;
fiDst.LastWriteTime = fiSrc.LastWriteTime;
fiDst.LastWriteTimeUtc = fiSrc.LastWriteTimeUtc;
if (!doCopyOnly)
{
File.Delete(src);
}
}
}
}
That's a general purpose method which does a lot more than you probably want to, but it moves a couple of gig files pretty quickly and reports progress.
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
|
|
|
|
|
The main objective is to compress the files into a container, but I want to at least be able to copy files with some type of progress notification at the very least first before I start making an algorithm for compression. Thanks for the source I'll study it and try to make something work.
|
|
|
|
|
Sir first of all Great Job and work done from your side.
Sir I want to learn C# at the professional level. I started working on your code (ME). I want to change the code and want to extend it (extend just for learning nothing else). I want to copy the equations directly just by selecting it. Can you please guide me that how can I copy directly my written equations in your ME?
(In step one I want to enable the copy feature and then in step two I want to add a functionality in the export menu to add "Export to Word").
Help Please
Thanks
|
|
|
|
|
Who's code are you talking about??
If you're talking about a certain article here on CP, drop your message in the forum at the bottom of the article, not here.
Each article is supported by the person who wrote it.
|
|
|
|
|
What are you talking about?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Ay caramba!
A message in a bottle.
|
|
|
|
|
How best can I create a Windows Form Application that regulates temperature and humidity for a green house using C#? I would want the inputs of humidity and temperature to be continuously generated. Please assist.
|
|
|
|
|
|
So you want experts to create that application completely for you? Have you tried anything? If not , i suggest you to go any freelancer website and post your need.
So much complexity in software comes from trying to make one thing do two things.
Sibeesh
|
|
|
|
|
i wanna to get text : فروش_آپارتمان-تهران-اسلام شهر-OQA2ADEAMAAwADUA.aspx
from string :
string s=@"href=\"فروش_آپارتمان-تهران-اسلام شهر-OQA2ADEAMAAwADUA.aspx\"\u003e\r\n \u003c";
I have tried this but not use :
string _conD="href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))";
MatchCollection _mat = Regex.Matches(s, _conD, RegexOptions.None);
|
|
|
|
|
Depending on the variance of the line you are extracting from, perhaps you could use a non-regex approach. Personally I would go down this route as RegEx syntax is tricky, but each to their own.
In you example you could do something like:
string x = s.Replace("href=\"", string.Empty);
x = x.Substring(0, x.IndexOf('\\');
.. or something like that, no visual studio to hand.
Regards,
Rob Philpott.
|
|
|
|