|
Thanks for the reply...
i don't want to use System Volume Information folder. But during enumeration process automatically the checking comes here, then generates an exception and terminates further execution. Is there any method to avoid these kind of system folders checking during enumeration?.
|
|
|
|
|
When you expect exceptions to be thrown catch them to avoid that the application terminates. In this case just ignore access denied exceptions and continue.
But there is no need to enumerate all directories when using a standard Windows folder for your application data.
|
|
|
|
|
|
thanks for the reply. . .
|
|
|
|
|
private static List<string> BadNames = new List<string>{"Adobe","CPMigrator","ServicePack","Symantec", "Server", "TumbleWeed"};
private static string targetFolder = "Common7";
static void Main(string[] args)
{
List<string> folders = GetFolders(@"C:\Program Files\");
string found = folders.FirstOrDefault(x=>x.ToUpper().EndsWith(targetFolder.ToUpper()));
}
public static List<string> GetFolders(string path)
{
List<string> folders = new List<string>();
foreach(string bad in BadNames)
{
if (path.ToUpper().Contains(bad.ToUpper()))
{
return folders;
}
}
try
{
folders = Directory.GetDirectories(path, "*.*", SearchOption.TopDirectoryOnly).ToList();
for (int i = 0; i <folders.Count; i++)
{
folders.AddRange(GetFolders(folders[i]));
}
}
catch (Exception)
{
}
return folders;
}
".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 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
modified 13-Apr-18 9:41am.
|
|
|
|
|
Smallest window in a string containing all the characters of another string
|
|
|
|
|
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
Try it yourself, you may find it is not as difficult as you think!
If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Looks a bit spammy to me.
|
|
|
|
|
The username does, but the message is clear of pink meat. And the user has been here for nearly two years.
I'll give it the benefit of the doubt for the moment - company names for your username are allowed.
Mind you, if he can't do that homework himself, I wouldn't use the company...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I am in the process of creating an intranet system for a local business. This system will contain a custom CRM, as well as various other components essential to the customers business.
They will shortly be switching their phone system to Skype.
We would like to develop a C# desktop app that talks with the skype application to detect when a phone call comes in, then flashes up various information for the user - such as customer name and account status.
Is there an API that will allow us to do this?
|
|
|
|
|
|
Except no-where on that page does it tell me how to integrate a C# application with skype. I don't want to create a bot, accept payments, conduct interviews or add call links to my web app.
I want to detect incoming calls on skype, and flash up additional data on the users screen.
And to clarify, I'm talking *desktop* application, not mobile.
modified 11-Apr-18 9:21am.
|
|
|
|
|
Sonetimes I think the better question is: How to turn Skype off ... cameras, mikes, status monitors, background zombies.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I created an excel user defined function using excel dna Add-In, My function should return a two dimentional array but when i call it from a cell (=mainView(2018-04-10) ) it displays only the first column name (FundName), below is my code:
<pre> public static object[,] mainView(DateTime dt)
{
int rows = 0;
int columns = 0;
const int columnsArrayIndex = 0;
DataTable dt = new DataTable();
object[,] allRecords = new object[0,0];
try
{
SqlConnection cnx = new SqlConnection("data source=...;initial catalog=...;integrated security=True");
cnx.Open();
string query = @"select FundName,...";
SqlCommand cmd = new SqlCommand(query, cnx);
using (SqlDataAdapter a = new SqlDataAdapter(cmd))
{
a.Fill(dt);
rows = dt.Rows.Count;
columns = dt.Columns.Count;
if (columns > 0 && rows > 0)
{
allRecords = new object[rows + 1, columns];
for (int i = 0; i <= columns - 1; i++)
{
allRecords[columnsArrayIndex, i] = dt.Columns[i].ColumnName;
}
for (int j = 0; j <= rows - 1; j++)
{
var rowItem = dt.Rows[j].ItemArray;
for (int k = 0; k <= rowItem.Length - 1; k++)
{
allRecords[j + 1, k] = rowItem[k];
}
}
}
}
}
catch
{
}
return allRecords;
} I would like to get all the rows of the select query result displayed in the excel, the result of the select query is dynamic, it changes when the date changes. What is missing in my code please so that i can get the result i want ? how can i display all the rows and columns of my query in the excel ?
|
|
|
|
|
I would suggest getting rid of the empty Catch block. There could be exceptions occurring, but you have no idea what they are because you're ignoring them.
Once you know what exceptions are occurring, you can solve them.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
I've never done such things, however I don't expect the content of a 2D array can be accepted by a single cell. You probably need to select a range of the correct size, then assign your UDF to the first cell of that range.
BTW: your code is very confusing as it seems to be using too many variable names to achieve what you want. And please never have an empty catch block, it will waste your and our time by NOT showing a lot of things that may be going wrong. Always catch an Exception and show the its entire ToString() result to the developer (and possibly later to the user).
|
|
|
|
|
Thank you, i found an example that returns the result in a range but when i did the same as the example i got an exception
"Exception de HRESULT : 0x800A03EC"
in this line
range.Value2 = result;
this is my code :
public static void LoadData(object[] args)
{
int rowPosition = Convert.ToInt32(args[0]);
int columnPosition = Convert.ToInt32(args[1]);
string sheetName = (string)args[2];
var application = (Microsoft.Office.Interop.Excel.Application)ExcelDnaUtil.Application;
var sheet = application.Sheets[Regex.Replace(sheetName, @"\[[^]]*\]", string.Empty)];
object[,] result = LoadFromDbData();
var startcell = sheet.Cells[rowPosition + 1, columnPosition + 1];
int rowCount = result.GetUpperBound(0)-result.GetLowerBound(0)+1;
int colCount = result.GetUpperBound(1)-result.GetLowerBound(1)+1;
var endcell = sheet.Cells[rowPosition+ rowCount, columnPosition+colCount];
try
{
Range range = (Range)sheet.Range(startcell, endcell);
range.Value2 = result;
}
catch (COMException e)
{
MessageBox.Show(e.Message);
}
}
|
|
|
|
|
Hi,
I have no idea what is going wrong, however this guy[^] probably knows.
And maybe looking at Exception.ToString() rather than Exception.Message would have helped too, as I told you before.
|
|
|
|
|
Hello,
I am new in MVC. I have one product table which has ProductID, ProductName and ProductRate. I have one dropdown list which has all the ProductName. Now I am trying to select the productname and upon this select, it should fill my textbox with ProductRate. Code is as below but it is not doing anything and no errors. Please help.
<script type="text/javascript">
function GetPrice(_this) {
var x = document.getElementById("productID"), selectedValue = x.value;
alert("_this" + _this.SelectedValue);
var pid = selectedValue;
alert(pid);
var url = '@Url.Action("GetPrice","Sales")';
alert(url);
$.ajax({
type:"POST",
url: 'Sales/GetPrice',
contentType: "application/json; charset=utf-8",
data: {ProductId: pid },
cache:false,
dataType: json,
async: true,
processData:false,
success: function (data)
{
alert("yay1");
},
failure: function (response) {
alert("Fail");
}
});
};
</script>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<div class="editor-field">
<div class="editor-label">
@Html.LabelFor(model => model.ProductId)
</div>
@Html.DropDownListFor(model => model.ProductId, new SelectList(ViewBag.ProductList, "ProductId", "ProductName" ), "Select Product", new { id = "productID", onchange="GetPrice(this);"})
@Html.ValidationMessageFor(model => model.ProductId, "", new { @class = "text-danger" })
<span class="glyphicon glyphicon-asterisk"></span>
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Rate)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Rate, new { id = "idRate"})
@Html.ValidationMessageFor(model => model.Rate)
</div>\
</fieldset>
}
Here is my Controller "SalesController.cs" code:
[HttpPost]
public JsonResult GetPrice(int ProductId)
{
return Json("");
}
Dhyanga
modified 9-Apr-18 11:49am.
|
|
|
|
|
I am able to fix it.
Please disregard this post.
Dhyanga
|
|
|
|
|
Hi guys, I have some code here written in C++ which creates 3x3 matrixes. I believe that it's using EmguCV Matrix. However, I planned to convert this into C# language but I've failed to do so. To the best of my knowledge, most online solutions guide me to use an array. Therefore, I wish to know is anyone expert in C# that may help me explain how can I convert this code to C#? I wish to know the syntax of it in C#. Thank you
<pre>Mat eulerAnglesToRotationMatrix(Vec3f &theta)
{
Mat R_x = (Mat_<double>(3,3) <<
1, 0, 0,
0, cos(theta[0]), -sin(theta[0]),
0, sin(theta[0]), cos(theta[0])
);
Mat R_y = (Mat_<double>(3,3) <<
cos(theta[1]), 0, sin(theta[1]),
0, 1, 0,
-sin(theta[1]), 0, cos(theta[1])
);
Mat R_z = (Mat_<double>(3,3) <<
cos(theta[2]), -sin(theta[2]), 0,
sin(theta[2]), cos(theta[2]), 0,
0, 0, 1);
Mat R = R_z * R_y * R_x;
return R;
}
|
|
|
|
|
The "EmuguCV Matrix" sample you are showing is using a "Mat" class; why do you think that arbitrarily using an "array" instead (because the "internet" says so) makes sense?
Mind you, I know nothing about C++ other than I dislike it because of MFC, etc. ...
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
EmuguCV is jsut a .NET wrapper around OpenCV.
That C++ code is just creating 3 Matrix instances and initializing them with all the values are each matrix position. The underlying code implements this as arrays.
Keep in mind that I haven't touched C++ in a really long time and have never used EmuguCV or OpenCV. But, in C#, I think the equivalent would be something like
Matrix R_x = new Matrix<double>(3, 3) {
1, 0, 0,
0, Math.Cos(theta[0]), -Math.Sin(theta[0]),
0, Math.Sin(theta[0]), Math.Cos(theta[0])
}
|
|
|
|
|
fyi: a literal translation of the first matrix to C#:
double[] theta = new double[]{0.4444};
Double[,] MatR_X = new double[3, 3]
{
{ 1.0, 0.0, 0.0 },
{ 0.0, Math.Cos(theta[0]), -Math.Sin(theta[0])},
{ 0.0, Math.Sin(theta[0]), Math.Sin(theta[0])}
}; However, you'll probably want to use the built-in Matrix3D Structure facilities in System.Windows.Media.Media3D: [^].
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
I have a Polynomial class, which has integer coefficients and an integer field called Characteristic. When positive, the Characteristic value denotes that the coefficients represent elements of the integers mod Characteristic. What I would like is for type checking to consider Polynomials with different Characteristic values to be different types - it shouldn't be possible to do operations between Polynomials with unlike characteristics, and it would be nice if the characteristic were very visible rather than buried inside the object state, for example. I would use a syntax like Polynomial<3> to declare a Polynomial of characteristic 3, but barring that possibility, what else could I try? I can't explicitly declare classes for each characteristic I need, because I don't know which ones I'll need until runtime.
|
|
|
|
|