|
Check your anti-virus settings.
|
|
|
|
|
It looks like your anti-virus's firewall is blocking the SMTP communications. Try to allow (inbound/outbound) connections by configuring the anti-virus's firewall on port 25 (default SMTP port) or any other port number that you are using. Also, you can check the default port numbers that you can enable for SMTP in the link below:
http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol[^]
See your antivirus documentation. It will tell you where to find the settings to achieve this.
modified 11-Jun-15 12:41pm.
|
|
|
|
|
In controller i wrote like this
------------------------------------------
public dynamic multipleimageupload(string image)
{
var aa = image.Split('\\');
var finalPath = aa[2];
var img = WebImage.GetImageFromRequest();
if (finalPath != null)
{
var fileName = finalPath.Replace(" ", "");
var fname = Path.GetFileNameWithoutExtension(fileName);
Regex regex = new Regex("[^a-zA-Z0-9]");
fname = regex.Replace(fname, "");
var fileExtension = Path.GetExtension(fileName);
string timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
var filenamewithtime = fname + "_" + timestamp + fileExtension;
var path = Path.Combine(Server.MapPath("~/Images/Imageupload"), filenamewithtime);
img.Save(path);
var finel = String.Format("/Images/Imageupload/{0}", filenamewithtime);
var userClient = new RestClient(string.Format("{0}/api/UserAccount/POSTImageUpload", MatchedInConfig.MatchedInApiUrl));
var request = new RestRequest(Method.POST);
var sessionResult = Session["UserID"];
request.AddParameter("UserID", sessionResult);
request.AddParameter("Avatar", finel);
var response = userClient.Execute(request);
return null;
}
return null;
}
-------------------------------------
in Api i wrote like this
----------------------------
public MI_PhotoAlbum POSTImageUpload(FacebookRegistrationModel model)
{
var userTable = new MI_PhotoAlbum();
().Query().Get().Where(a => a.UserId == model.UserID).SingleOrDefault();
userTable.UserId = model.UserID;
userTable.ImageUrl = model.Avatar;
_unitOfWork.Repository<MI_PhotoAlbum>().Insert(userTable);
_unitOfWork.Save();
return userTable;
}
--------------------------
in partialview
---------------------
<div class="photo-upload-bar">
<i class="fa fa-image"></i>Photos<div class="btn btn-primary btn-xs pull-right btn-upload" >Upload <i class="fa fa-plus"></i>
<input id="choose" type='file' name="fileUpload" onchange="readfile(this);" accept="image/x-png, image/gif, image/jpeg" /></div>
@* <label class="control-label col-md-2">Image</label>*@
<div class="col-md-10">
<img id="image_preview" src="~/Areas/Admin/Images/NoImage/NO_IMAGE.jpg" alt="your image" width="100" height="100" />
<input id="RemoveBtnID" style="display: none" type="button" value="Remove" onclick="Removefun()" />
@*<input id="choose" type='file' name="fileUpload" onchange="readfile(this);" accept="image/x-png, image/gif, image/jpeg" />*@
<span id="para" style="color: red"></span>
<span id="SpanImageId" style="color: red;"></span>
<br />
<span id="SpanimageId" style="color: red;"></span>
</div>
<script type="text/javascript">
jQuery(document).ready(function () {
ComponentsEditors.init();
});
var url = window.URL || window.webkitURL;
$('#choose').change(function () {
alert("hii");
var newInterests = $("#choose").val();
if (newInterests != "") {
$.ajax({
url: "../account/multipleimageupload/?image=" + newInterests,
type: "Post",
contentType: 'application/json; charset=utf-8',
success: function (data) {
if (data != 0) {
}
else {
}
},
error: function () { }
});
}
else {
}
var fileExtension = ['jpeg', 'jpg', 'png', 'gif', 'bmp'];
if ($.inArray($(this).val().split('.').pop().toLowerCase(), fileExtension) == -1) {
document.getElementById('para').innerHTML = "<span>Choose Only Image Files</span>";
Removefun();
document.getElementById('Upload').innerHTML = "<span></span>";
$('#choose').val('');
$('#image_preview').attr('src', "/Areas/Admin/Images/NoImage/NO_IMAGE_Thumb.jpg");
return false;
}
else {
$("#SpanimageId").text("");
document.getElementById('para').innerHTML = "<span></span>";
document.getElementById('Upload').innerHTML = "<span></span>";
}
});
function readfile(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#image_preview').attr('src', e.target.result);
var imagesize = input.files[0].size / 2048;
var ImageSize = imagesize / 2048;
if (ImageSize > 2) {
alert("Image size should be less than 2MB");
$('#image_preview').attr('src', "/Areas/Admin/Images/NoImage/NO_IMAGE_Thumb.jpg");
$('#RemoveBtnID').hide();
$('#choose').show();
return false;
}
else {
$('#RemoveBtnID').show();
$("#SpanimageId").text("");
}
}
reader.readAsDataURL(input.files[0]);
}
}
function Removefun() {
$('#image_preview').attr('src', "/Areas/Admin/Images/NoImage/NO_IMAGE.jpg");
$('#RemoveBtnID').hide();
$('#choose').show();
}
</script>
|
|
|
|
|
Given that you want some javascript then the javascript forum[^] might be a more appropriate location for this question!
|
|
|
|
|
SOLUTION
make sure to refresh the folder your checking to see if the files have actually deleted or not.
In this case they were (the code works fine), just i wasn't refreshing desktop etc haha, oh well.
STUPID QUESTION CONTINUES-------------
http://s000.tinyupload.com/index.php?file_id=06162948769787766673[^]
The link above is a localized example of my problem.
I cannot for the life of me figure out why file.exists or any kind of permission checks don't work!
Its like .NET just says oh.. I might delete this, might not, might say i did but actually didn't, or didn't but actually.. didn't, maybe i will if you give me time... but i still wont tell you even if i did or didn't...
so... please save the last few strands of hair on my head!
Thanks!
(For ease of viewing: pastebin)
or right here:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using IWshRuntimeLibrary;
namespace test
{
public partial class TestFileDelete : Form
{
Boolean flag = true;
public TestFileDelete()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.button1.Enabled = false;
if (this.button1.Enabled == false) return;
int switchnum = (flag) ? 1 : 0;
int newnum = (flag) ? 0 : 1;
if (flag == true)
{
flag = false;
}
else
{
flag = true;
}
String StartMenuProgName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu), "Programs", "skbt config", "config " + newnum);
Dictionary<UInt32, String> Shortcuts = new Dictionary<uint, string>() {
{0,Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Start Keepalive (" + "config " + newnum + ").lnk")},
{1,Path.Combine(StartMenuProgName, "Start Keepalive.lnk")},
{2,Path.Combine(StartMenuProgName, "Auto Restart Test.lnk")},
{3,Path.Combine(StartMenuProgName, "Manual Restart.lnk")},
{4,Path.Combine(StartMenuProgName, "Manual Start.lnk")},
{5,Path.Combine(StartMenuProgName, "Manual Stop.lnk")},
{6,Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "README.txt")}
};
foreach (KeyValuePair<UInt32, String> shortcut in Shortcuts)
{
while (System.IO.File.Exists(Path.GetFullPath(shortcut.Value.ToString())))
{
if (this.checkBox1.Checked == true)
{
Thread.Sleep(300);
}
System.IO.File.Delete(Path.GetFullPath(shortcut.Value.ToString()));
}
}
if (Directory.Exists(StartMenuProgName)) { Directory.Delete(StartMenuProgName, true); }
StartMenuProgName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu), "Programs", "skbt config", "config " + switchnum);
String BatchLibPath = @"c:\test";
if (!addShortcut(
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Start Keepalive (" + "config " + switchnum + ").lnk"),
Path.Combine(BatchLibPath, "start_keepalive.bat")))
{
MessageBox.Show("There was an error creating a shortcut in the Start Menu (0).");
}
if (!addShortcut(
Path.Combine(StartMenuProgName, "Start Keepalive.lnk"),
Path.Combine(BatchLibPath, "start_keepalive.bat")))
{
MessageBox.Show("There was an error creating a shortcut in the Start Menu (1).");
}
if (!addShortcut(
Path.Combine(StartMenuProgName, "Auto Restart Test.lnk"),
Path.Combine(BatchLibPath, "control", "auto_restart.bat")))
{
MessageBox.Show("There was an error creating a shortcut in the Start Menu (2).");
}
if (!addShortcut(
Path.Combine(StartMenuProgName, "Manual Restart.lnk"),
Path.Combine(BatchLibPath, "control", "manual_restart.bat")))
{
MessageBox.Show("There was an error creating a shortcut in the Start Menu (3).");
}
if (!addShortcut(
Path.Combine(StartMenuProgName, "Manual Start.lnk"),
Path.Combine(BatchLibPath, "control", "manual_start.bat")))
{
MessageBox.Show("There was an error creating a shortcut in the Start Menu (4).");
}
if (!addShortcut(
Path.Combine(StartMenuProgName, "Manual Stop.lnk"),
Path.Combine(BatchLibPath, "control", "manual_stop.bat")))
{
MessageBox.Show("There was an error creating a shortcut in the Start Menu (5).");
}
this.button1.Enabled = true;
}
private static Boolean addShortcut(String ShortcutPath, String TargetPath)
{
try
{
WshShell shell = new WshShell();
IWshShortcut link = (IWshShortcut)shell.CreateShortcut(ShortcutPath);
link.TargetPath = TargetPath;
if (!Directory.Exists(Path.GetDirectoryName(ShortcutPath)))
{
Directory.CreateDirectory(Path.GetDirectoryName(ShortcutPath));
}
link.Save();
return true;
}
catch
{
return false;
}
}
protected virtual bool IsFileLocked(FileInfo file)
{
FileStream stream = null;
try
{
stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
}
catch (IOException)
{
return true;
}
finally
{
if (stream != null)
stream.Close();
}
return false;
}
}
}
modified 9-Jun-15 23:59pm.
|
|
|
|
|
public partial class Form3 : Form
{
private OleDbConnection connection = new OleDbConnection();
public Form3()
{
InitializeComponent();
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Certificates-track\certificates-track.accdb;Persist Security Info=False;";
private void button1_Click(object sender, EventArgs e)
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string query="Select * from StudentData where Regdno='" + Regdno_txt.Text + "';";
command.CommandText = query;
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Name_txt.Text = reader["Name"].ToString();
Program_txt.Text = reader["Program"].ToString();
Branch_txt.Text = reader["Branch"].ToString();
}
connection.Close();
}
|
|
|
|
|
Your code is vulnerable to SQL Injection[^].
NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
using (OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Certificates-track\certificates-track.accdb;Persist Security Info=False;"))
using (OleDbCommand command = new OleDbCommand("Select Name, Program, Branch from StudentData where Regdno = ?", connection))
{
command.Parameters.AddWithValue("Regdno", Regdno_txt.Text);
connection.Open();
using (OleDbDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection))
{
while (reader.Read())
{
Name_txt.Text = Convert.ToString(reader["Name"]);
Program_txt.Text = Convert.ToString(reader["Program"]);
Branch_txt.Text = Convert.ToString(reader["Branch"]);
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello,
I'm trying to use the DynamicExpression class to parse a string and get an expression tree.
This works fine for simple cases, but when the input string contains a Select() command, this gives me the error "No applicable aggregate method 'Select' exists".
For example, let's say I want to build the expression tree below:
x => x.MyCollection.Select(y => y.SomeInt)
If I pass the string "x.MyCollection.Select(SomeInt)" to the ParseLambda method, I get the error mentioned above.
Does anyone know to get around this or give me an alternative to transform a string to a lamba expression?
Thanks in advance.
|
|
|
|
|
HUONG Minh-Luong wrote:
x => x.MyCollection.Select(y => y.SomeInt)
...
"x.MyCollection.Select(SomeInt)"
Why are you passing a string which doesn't match your lambda expression?
Did you try using the string "x => x.MyCollection.Select(y => y.SomeInt)" instead?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 9-Jun-15 13:47pm.
|
|
|
|
|
It doesn't work either. It says that y is not a property of MyCollection type.
This string works "x.MyCollection.Any(SomeInt==1)", so I figured that Select should work the same way.
|
|
|
|
|
I have a DataGrid that displays information about trailers. I decided to change the location column to a DropDownList so the location can be easily changed. But I am not sure how to populate the DropDownList.
<asp:DataGrid runat="server" CssClass="tblResults" OnItemDataBound="dgList_ItemCreated" OnRowDataBound="OnRowDataBound" AllowSorting="true" OnSortCommand="dgTrailer_Sort" ID="dgTrailers" DataKeyField="ID" AutoGenerateColumns="false">
<Columns>
<asp:BoundColumn DataField="TrailerOwner" HeaderText="Owner" SortExpression="TrailerOwner"></asp:BoundColumn>
<asp:BoundColumn DataField="TrailerMake" HeaderText="Trailer Make" SortExpression="TrailerMake"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Trailer Location">
<itemtemplate>
<asp:DropDownList ID="ddlLocation" runat="server">
</asp:DropDownList>
</itemtemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
I have a DropDownList for location already (called ddlTrailerLocation) so the user can select the location for the trailer and then the DataGrid displays all that information. Here's how I populated ddlTrailerLocation:
protected void PopulateDDLs()
{
DataSet dsTrailerLocation = DataUtils.GetAllGenSmall(Company.Current.CompanyID, "Description", "", 1, false, "Description", false, "TrailerLocationNOCODE", 0);
if (dsTrailerLocation.Tables[0].Rows.Count > 0)
{
ddlTrailerLocation.DataSource = dsTrailerLocation;
ddlTrailerLocation.DataValueField = "Description";
ddlTrailerLocation.DataTextField = "Description";
ddlTrailerLocation.DataBind();
ddlTrailerLocation.Items.Insert(0, new ListItem("Select One", "0"));
}
else
{
ddlTrailerLocation.Items.Insert(0, new ListItem("No Locations Entered", "0"));
}
}
Is there something I can add to this method to display the correct location of each trailer in the DataGrid? The location column was displaying the location but is now just showing an empty DropDownList
|
|
|
|
|
If you have DropDownList control nested in your DataGridView, the best place to populate contents is RowDataBound event. It will populate dropdownlist control based on current row data.
Try something like below to find dropdownlist control in your current row and then bind the data.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
var dropDownList = e.Row.FindControl("ddlLocation") as DropDownList;
}
}
modified 20-Sep-20 21:01pm.
|
|
|
|
|
I can’t download and use official telegram api in c# to create chat program.
I need steep-by-steep tutorial to do this. And may be one little sample program in c#.
|
|
|
|
|
Sorry but this site does not provide either step by step instructions, or code samples, to order. If you wish to learn this API then go to https://core.telegram.org/[^].
|
|
|
|
|
Hello guys. I took some code from web for running external process in my windows form application. This code contains these lines
process.WaitForExit(10 * 60 * 1000);
Thread.Sleep(200);
try
{
process.Kill();
process.WaitForExit(5000);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
What do these lines of code mean....thanks for any input.
|
|
|
|
|
How about this. Click on the WaitForExit part and hit F1.
Click on Sleep and hit F1.
Click on Kill and hit F1.
Click on WaitForExit and hit F1.
The documentation makes it pretty clear what each of these statements does.
|
|
|
|
|
Downvote countered.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Give a man a fish or teach him to fish.
Apparently, the wrong answer was to teach him to fish.
|
|
|
|
|
I think you're right: he was expecting a whole fish-finger sandwich...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Just to add to what Dave says - if you can't understand (or work out for yourself) what trivial code fragments like that do, I would strongly suggest you stop downloading code from the internet.
If you don't know what code does, you don't know that it (a) does what you want, or (b) does nothing malicious or dangerous.
Would you download an EXE file at random and just run it on your computer? No? So why do the same with code...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
process.WaitForExit(10 * 60 * 1000); --> This starts a wait that remains waiting 10 minuts the exit of the process
Thread.Sleep(200); --> When the wait is finised because the timer expires or the process ends we wait 200 milliseconds
try
{
process.Kill(); --> Try to kill the process manually
process.WaitForExit(5000); --> This wait 5 seconds to check if the process has been killed
}
catch (Exception ex)
{
MessageBox.Show(ex.Message); --> If some problem happen in the try loop it shows the message error using a MessageBox
}
I hope this explanation line by line helps you.
|
|
|
|
|
Hey, Im a C# nooblord. This problem probably has a very easy solution, but im unable tot find out what i did wrong. Could you help me fix it please ? Also could you write the code i need to fix this? Thank you .
http://imgur.com/vqHjMjE[^]
|
|
|
|
|
I guess your intent is to write
if (cislo > nahodne)
instead.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Oh. Thanks
|
|
|
|
|