|
Hi Luc!
You are right, this is actually a UNC path
I believe it is still considered a hyperlink, but I may have used the wrong terminology, I used hyperlinks because of the c# method terminology.
|
|
|
|
|
Here is what works, thanks to all that contributed and answered
oSheet.Cells[row, column] = data;
string cell = oSheet.Cells[row, column].ToString();
if ((data.Contains(@"\\")) && (createSheet == false))
{
Excel.Range rng = (Excel.Range)oSheet.Cells[row, column];
oSheet.Hyperlinks.Add(rng, string.Empty, data, "", data);
}
|
|
|
|
|
Hi,
I'm new in DB programming in .net context and I have a question.
If I use a DB in my internet site (es www.mysite.org), I can quering this DB from my desktop application using ADO.net?
Thank a lot.
Alex
|
|
|
|
|
Yes, as long as the database server can be connected to remotely. If it can't be done that way, you can always create a web service to handle the access, and just connect to the web service instead.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
My 5! Good answer since it's most likely that the webserver is behind a firewall. A webservice is a good and viable solution.
|
|
|
|
|
If it's hosted then the database will be likely hiding behind a firewall. Yup, webservices are the way to go
I are Troll
|
|
|
|
|
I second (third?) a Web Service. But I question the need to query from the client side. You'll have to be very wary of SQL injection, but you can probably minimize the risks.
|
|
|
|
|
I want to add directory security to certain folders on my system,
the code is
NTAccount identity = new NTAccount(Account);
SecurityIdentifier sid = (SecurityIdentifier)identity.Translate(typeof(SecurityIdentifier));
DirectoryInfo dInfo = new DirectoryInfo(Dir);
DirectorySecurity dSecurity = dInfo.GetAccessControl(AccessControlSections.Access);
dSecurity.AddAccessRule(new FileSystemAccessRule(sid , Rights, ControlType));
dInfo.SetAccessControl(dSecurity);
but i keep getting this error:
some or all identity references could not be translated
|
|
|
|
|
Why doesnt it download every files in this code?
All files that have been downloaded is shown in the listview, but when i open the folder where the files are, then some of files has not been downloaded.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnDownload_Click(object sender, EventArgs e)
{
string p1 = @"\";
string p2 = TBSaveTo.Text;
string p3 = TBSaveAs.Text;
listView1.Items.Clear();
label1.Visible = false;
HttpWebRequest request = null;
HttpWebResponse response = null;
WebClient wc = new WebClient();
string ret = "";
for (int i = 2000; i < 2312; i++)
{
string sFiles = string.Format("http://www.svenskaspel.se/includes/xmlelements/XMLresultat.asp?produktid=30&omgang={0}", +i);
listView1.Items.Add(new ListViewItem(p2 + p1 + "omgang=" + i + p3));
{
try
{
request = (HttpWebRequest)WebRequest.Create(sFiles.Trim());
request.Method = "GET";
request.ContentType = "application/x-www-form-urlencoded";
request.Timeout = 15000;
response = (HttpWebResponse)request.GetResponse();
ret = new StreamReader(response.GetResponseStream(),
Encoding.Default).ReadToEnd();
wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
wc.DownloadFileAsync(new Uri(sFiles.Trim()), String.Format(p2 + p1 + "omgang=" + i + p3, Path.GetExtension(sFiles)));
wc.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wc_DownloadFileCompleted);
response.Close();
}
catch { }
finally
{
if (response != null)
{
response.Close();
}
}
}
}
}
private void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
this.label1.Visible = false;
}
private void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
this.label1.Visible = true;
}
private void btnBrowse_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
TBSaveTo.Text = folderBrowserDialog1.SelectedPath;
}
}
}
}
/Kenneth
|
|
|
|
|
Member 2168103 wrote: catch { }
that is just stupid.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Agreed - perhaps correct exception handling should be the first lesson for anyone learning to code rather than just an after thought.
|
|
|
|
|
Yes. I also agree very much.
So mixing webclient in that code sucks because it doesnt support concurrent I/O operations like the exception says( ).Thank you!
|
|
|
|
|
You missed the point entirely.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
what do you mean?
first i got books but my understandings in english isnt the best and thats also why it can be difficult for me to understans, so pls explain what i missed???
|
|
|
|
|
Of course it displays the document in the listview. You add it in before you even attempt the download. Looking at your code, it appears from a cursory glance that you are closing your response stream before it has a chance to download the files.
Also, as Luc has said, it's an extremely bad idea to consume exceptions - never, ever, put in code that says catch { } without a good reason (there are some cases where you can get away with this, but they are the exception rather than the norm).
|
|
|
|
|
Pete O'Hanlon wrote: never, ever, put in code that says catch { } without a good reason
and, if and when there is such good reason, explain it in all its glory in a comment, so the catch block holds something useful.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
|
Word up.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
I try to copy a TreeViewItem with all of it's items from a TreeView. When I try to paste it in the same TreeView but in an other location, I stumble on an error. This is my sample of the relevant code:
Some usefull datatypes
TreeView tvFolders;
TreeViewItem bufferFolder;
The method to copy the selected TreeViewItem
private void Copy(object sender, RoutedEventArgs e)
{
if (tvFolders.SelectedItem == null)
return;
bufferFolder = tvFolders.SelectedItem as TreeViewItem;
}
The method to paste the selected TreeViewItem
private void Paste(Object sender, RoutedEventArgs e)
{
if (bufferFolder == null || tvFolders.SelectedItem == null)
return;
TreeViewItem selectedFolder = tvFolders.SelectedItem as TreeViewItem;
selectedFolder.Items.Add(bufferFolder);
}
When I try to execute the selectedFolder.Items.Add(bufferFolder); instruction in the Paste() method, I get an InvalidOperationException with this following message:
"Element already has a logical parent. It must be detached from the old parent before it is attached to a new one."
The only way I know to "detach" the TreeViewItem is to remove it in Copy() method. But doing that actually redesigns the Copy() method to my Cut() method. That is not what I want, but it makes the Paste() method to work
I have tried several ways to copy the TreeViewItem with: "deep copy", "shallow copy", a derivided class of TreeViewItem with Serializable attribute and ISerializable interface as well as using the ICloneable interface but I have not had any luck.
Any suggestions for a soluation?
|
|
|
|
|
You are approaching the problem in the wrong way. Basically, what you need to do is to take a copy of the data that makes up the TreeViewItem that you are interested in, and add this into the relevant location instead. As you have found, each element can only have one parent (the Visual and Logical Trees are tree structures after all), and it takes some extreme hackery to accomplish the "reparenting". By doing things the MVVM way instead, you will make things a lot easier on yourself.
|
|
|
|
|
Yes, I thought I was approaching this in a wrong way.
But how do I copy of all data that is within each TreeViewItem?
It's rather tidious to pass all properties to a new instance of a TreeViewItem from the one I would like to copy/clone.
Any example?
|
|
|
|
|
|
Is it possible to do Video streaming using C# handler
Expression blend 4 with VS2010 C# handler
|
|
|
|
|
It is quite possible. If you are using Expression Blend 4 I assume you are using WPF or Silverlight.
Video streaming is possible in both WPF and Silverlight.
See here[^] for a simple example.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
i am looking for something that is able to stream a video from for example,
i uploaded this video onto the server
www.xxxxx.com/video.wmv
how do i stream it on click event handler, for it to stream this specific video onto the media element on expression blend 4
|
|
|
|